当前位置: 首页>>代码示例>>PHP>>正文


PHP change_user_bonus函数代码示例

本文整理汇总了PHP中change_user_bonus函数的典型用法代码示例。如果您正苦于以下问题:PHP change_user_bonus函数的具体用法?PHP change_user_bonus怎么用?PHP change_user_bonus使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了change_user_bonus函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: cancel_order

/**
 * 取消一个用户订单
 *
 * @access  public
 * @param   int         $order_id       订单ID
 * @param   int         $user_id        用户ID
 *
 * @return void
 */
function cancel_order($order_id, $user_id = 0)
{
    /* 查询订单信息,检查状态 */
    $sql = "SELECT user_id, order_id, order_sn , surplus , integral , bonus_id, order_status, shipping_status, pay_status, pay_id, money_paid " . " FROM " . $GLOBALS['ecs']->table('order_info') . " WHERE order_id = '{$order_id}'";
    $order = $GLOBALS['db']->getRow($sql);
    if (empty($order)) {
        $GLOBALS['err']->add($GLOBALS['_LANG']['order_exist']);
        return false;
    }
    // 如果用户ID大于0,检查订单是否属于该用户
    if ($user_id > 0 && $order['user_id'] != $user_id) {
        $GLOBALS['err']->add($GLOBALS['_LANG']['no_priv']);
        return false;
    }
    // 订单状态只能是“未确认”
    if ($order['order_status'] != OS_UNCONFIRMED) {
        $GLOBALS['err']->add($GLOBALS['_LANG']['current_os_not_unconfirmed']);
        return false;
    }
    $pay_status = PS_UNPAYED;
    // 如果已付款,走退款流程
    if ($order['pay_status'] == PS_PAYED && $order['money_paid'] > 0) {
        //查找paylog
        $sql = "SELECT * FROM " . $GLOBALS['ecs']->table('pay_log') . " WHERE order_id = '{$order['order_id']}' AND pay_id = '{$order['pay_id']}' AND is_paid = 1 ORDER BY log_id DESC LIMIT 1";
        $paylog = $GLOBALS['db']->getRow($sql);
        //退款申请
        $refund_data = array('order_id' => $order['order_id'], 'log_id' => $paylog['log_id'], 'outer_sn' => $paylog['outer_sn'], 'pay_id' => $order['pay_id'], 'user_id' => $order['user_id'], 'order_amount' => $order['money_paid'], 'refund_amount' => $order['money_paid'], 'create_time' => time());
        $pay_status = PS_REFUNDING;
        $payment = payment_info($order['pay_id']);
        if ($payment['self_refund'] == 1) {
            //支持自助退款
            include_once ROOT_PATH . 'include/modules/payment/' . $payment['pay_code'] . '.php';
            $pay_obj = new $payment['pay_code']();
            $result = $pay_obj->refund($order, unserialize_config($payment['pay_config']));
            if (!$result) {
                $GLOBALS['err']->add('退款失败,请联系客服处理');
            } else {
                $pay_status = PS_REFUND;
                $refund_data['refund_admin'] = 0;
                $refund_data['refund_time'] = time();
                $refund_data['finish_time'] = time();
                $refund_data['status'] = 2;
                //TODO:发送微信模板消息或短信通知
            }
        } else {
            $GLOBALS['err']->add('等待客服审核退款申请');
        }
        $GLOBALS['db']->autoExecute($GLOBALS['ecs']->table('refund_apply'), $refund_data, 'INSERT');
    }
    //将用户订单设置为取消
    $sql = "UPDATE " . $GLOBALS['ecs']->table('order_info') . " SET order_status = " . OS_CANCELED . ", pay_status = " . $pay_status . " WHERE order_id = '{$order_id}'";
    if ($GLOBALS['db']->query($sql)) {
        /* 记录log */
        order_action($order['order_sn'], OS_CANCELED, $order['shipping_status'], PS_UNPAYED, $GLOBALS['_LANG']['buyer_cancel'], 'buyer');
        /* 退货用户余额、积分、红包 */
        if ($order['user_id'] > 0 && $order['surplus'] > 0) {
            $change_desc = sprintf($GLOBALS['_LANG']['return_surplus_on_cancel'], $order['order_sn']);
            log_account_change($order['user_id'], $order['surplus'], 0, 0, 0, $change_desc);
        }
        if ($order['user_id'] > 0 && $order['integral'] > 0) {
            $change_desc = sprintf($GLOBALS['_LANG']['return_integral_on_cancel'], $order['order_sn']);
            log_account_change($order['user_id'], 0, 0, 0, $order['integral'], $change_desc);
        }
        if ($order['user_id'] > 0 && $order['bonus_id'] > 0) {
            change_user_bonus($order['bonus_id'], $order['order_id'], false);
        }
        /* 如果使用库存,且下订单时减库存,则增加库存 */
        if ($GLOBALS['_CFG']['use_storage'] == '1' && $GLOBALS['_CFG']['stock_dec_time'] == SDT_PLACE) {
            change_order_goods_storage($order['order_id'], false, 1);
        }
        /* 修改订单 */
        $arr = array('bonus_id' => 0, 'bonus' => 0, 'integral' => 0, 'integral_money' => 0, 'surplus' => 0);
        update_order($order['order_id'], $arr);
        return true;
    } else {
        return false;
    }
}
开发者ID:GYWang1983,项目名称:fruit,代码行数:87,代码来源:lib_transaction.php

示例2: cancel_order

/**
 * 取消一个用户订单
 *
 * @access  public
 * @param   int         $order_id       订单ID
 * @param   int         $user_id        用户ID
 *
 * @return void
 */
function cancel_order($order_id, $user_id = 0)
{
    /* 查询订单信息,检查状态 */
    $sql = "SELECT user_id, order_id, order_sn , surplus , integral , bonus_id, order_status, shipping_status, pay_status FROM " . $GLOBALS['ecs']->table('order_info') . " WHERE order_id = '{$order_id}'";
    $order = $GLOBALS['db']->GetRow($sql);
    if (empty($order)) {
        $GLOBALS['err']->add(L('order_exist'));
        return false;
    }
    // 如果用户ID大于0,检查订单是否属于该用户
    if ($user_id > 0 && $order['user_id'] != $user_id) {
        $GLOBALS['err']->add(L('no_priv'));
        return false;
    }
    // 订单状态只能是“未确认”或“已确认”
    if ($order['order_status'] != OS_UNCONFIRMED && $order['order_status'] != OS_CONFIRMED) {
        $GLOBALS['err']->add(L('current_os_not_unconfirmed'));
        return false;
    }
    //订单一旦确认,不允许用户取消
    if ($order['order_status'] == OS_CONFIRMED) {
        $GLOBALS['err']->add(L('current_os_already_confirmed'));
        return false;
    }
    // 发货状态只能是“未发货”
    if ($order['shipping_status'] != SS_UNSHIPPED) {
        $GLOBALS['err']->add(L('current_ss_not_cancel'));
        return false;
    }
    // 如果付款状态是“已付款”、“付款中”,不允许取消,要取消和商家联系
    if ($order['pay_status'] != PS_UNPAYED) {
        $GLOBALS['err']->add(L('current_ps_not_cancel'));
        return false;
    }
    //将用户订单设置为取消
    $sql = "UPDATE " . $GLOBALS['ecs']->table('order_info') . " SET order_status = '" . OS_CANCELED . "' WHERE order_id = '{$order_id}'";
    if ($GLOBALS['db']->query($sql)) {
        /* 记录log */
        order_action($order['order_sn'], OS_CANCELED, $order['shipping_status'], PS_UNPAYED, L('buyer_cancel.buyer'));
        /* 退货用户余额、积分、红包 */
        if ($order['user_id'] > 0 && $order['surplus'] > 0) {
            $change_desc = sprintf(L('return_surplus_on_cancel'), $order['order_sn']);
            log_account_change($order['user_id'], $order['surplus'], 0, 0, 0, $change_desc);
        }
        if ($order['user_id'] > 0 && $order['integral'] > 0) {
            $change_desc = sprintf(L('return_integral_on_cancel'), $order['order_sn']);
            log_account_change($order['user_id'], 0, 0, 0, $order['integral'], $change_desc);
        }
        if ($order['user_id'] > 0 && $order['bonus_id'] > 0) {
            change_user_bonus($order['bonus_id'], $order['order_id'], false);
        }
        /* 如果使用库存,且下订单时减库存,则增加库存 */
        if (C('use_storage') == '1' && C('stock_dec_time') == SDT_PLACE) {
            change_order_goods_storage($order['order_id'], false, 1);
        }
        /* 修改订单 */
        $arr = array('bonus_id' => 0, 'bonus' => 0, 'integral' => 0, 'integral_money' => 0, 'surplus' => 0);
        update_order($order['order_id'], $arr);
        return true;
    } else {
        die($GLOBALS['db']->errorMsg());
    }
}
开发者ID:connwap135,项目名称:ectouch,代码行数:72,代码来源:transaction_helper.php

示例3: cancel_order

/**
 * 取消一个用户订单
 *
 * @access  public
 * @param   int         $order_id       订单ID
 * @param   int         $user_id        用户ID
 * @param   int         $action         取消类型
 *
 * @return void
 */
function cancel_order($order_id, $user_id = 0, $action = OS_CANCELED)
{
    /* 查询订单信息,检查状态 */
    $sql = "SELECT user_id, order_id, order_sn , surplus , integral , bonus_id, order_status, shipping_status, pay_status, pay_id, money_paid " . " FROM " . $GLOBALS['ecs']->table('order_info') . " WHERE order_id = '{$order_id}'";
    $order = $GLOBALS['db']->GetRow($sql);
    if (empty($order)) {
        $GLOBALS['err']->add($GLOBALS['_LANG']['order_exist']);
        return false;
    }
    // 如果用户ID大于0,检查订单是否属于该用户
    if ($user_id > 0 && $order['user_id'] != $user_id) {
        $GLOBALS['err']->add($GLOBALS['_LANG']['no_priv']);
        return false;
    }
    // 订单状态只能是“未确认”
    if ($order['order_status'] != OS_UNCONFIRMED) {
        $GLOBALS['err']->add($GLOBALS['_LANG']['current_os_not_unconfirmed']);
        return false;
    }
    // 如果已付款,走退款流程
    if ($order['pay_status'] == PS_PAYED && $order['money_paid'] > 0) {
        $payment = payment_info($order['pay_id']);
        include_once ROOT_PATH . 'include/modules/payment/' . $payment['pay_code'] . '.php';
        $pay_obj = new $payment['pay_code']();
        $result = $pay_obj->refund($order, unserialize_config($payment['pay_config']));
        if (!$result) {
            $GLOBALS['err']->add('退款失败,请联系客服处理。');
            return false;
        }
    }
    //将用户订单设置为取消
    $sql = "UPDATE " . $GLOBALS['ecs']->table('order_info') . " SET order_status = '{$action}', pay_status = " . PS_UNPAYED . " WHERE order_id = '{$order_id}'";
    if ($GLOBALS['db']->query($sql)) {
        /* 记录log */
        order_action($order['order_sn'], $action, $order['shipping_status'], PS_UNPAYED, $GLOBALS['_LANG']['buyer_cancel'], 'buyer');
        /* 退货用户余额、积分、红包 */
        if ($order['user_id'] > 0 && $order['surplus'] > 0) {
            $change_desc = sprintf($GLOBALS['_LANG']['return_surplus_on_cancel'], $order['order_sn']);
            log_account_change($order['user_id'], $order['surplus'], 0, 0, 0, $change_desc);
        }
        if ($order['user_id'] > 0 && $order['integral'] > 0) {
            $change_desc = sprintf($GLOBALS['_LANG']['return_integral_on_cancel'], $order['order_sn']);
            log_account_change($order['user_id'], 0, 0, 0, $order['integral'], $change_desc);
        }
        if ($order['user_id'] > 0 && $order['bonus_id'] > 0) {
            change_user_bonus($order['bonus_id'], $order['order_id'], false);
        }
        /* 如果使用库存,且下订单时减库存,则增加库存 */
        if ($GLOBALS['_CFG']['use_storage'] == '1' && $GLOBALS['_CFG']['stock_dec_time'] == SDT_PLACE) {
            change_order_goods_storage($order['order_id'], false, 1);
        }
        /* 修改订单 */
        $arr = array('bonus_id' => 0, 'bonus' => 0, 'integral' => 0, 'integral_money' => 0, 'surplus' => 0);
        update_order($order['order_id'], $arr);
        return true;
    } else {
        die($GLOBALS['db']->errorMsg());
    }
}
开发者ID:GYWang1983,项目名称:fruit,代码行数:69,代码来源:lib_transaction.php


注:本文中的change_user_bonus函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。