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


PHP integral_to_give函数代码示例

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


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

示例1: order_refund

     $refund_type = $_REQUEST['refund'];
     $refund_note = $_REQUEST['refund'];
     order_refund($order, $refund_type, $refund_note);
 }
 /* 记录log */
 order_action($order['order_sn'], OS_RETURNED, SS_UNSHIPPED, PS_UNPAYED, $action_note);
 /* 如果订单用户不为空,计算积分,并退回 */
 if ($order['user_id'] > 0) {
     /* 取得用户信息 */
     $user = user_info($order['user_id']);
     $sql = "SELECT  goods_number, send_number FROM" . $GLOBALS['ecs']->table('order_goods') . "\n                WHERE order_id = '" . $order['order_id'] . "'";
     $goods_num = $db->query($sql);
     $goods_num = $db->fetchRow($goods_num);
     if ($goods_num['goods_number'] == $goods_num['send_number']) {
         /* 计算并退回积分 */
         $integral = integral_to_give($order);
         log_account_change($order['user_id'], 0, 0, -1 * intval($integral['rank_points']), -1 * intval($integral['custom_points']), sprintf($_LANG['return_order_gift_integral'], $order['order_sn']));
     }
     /* todo 计算并退回红包 */
     return_order_bonus($order_id);
 }
 /* 如果使用库存,则增加库存(不论何时减库存都需要) */
 if ($_CFG['use_storage'] == '1') {
     if ($_CFG['stock_dec_time'] == SDT_SHIP) {
         change_order_goods_storage($order['order_id'], false, SDT_SHIP);
     } elseif ($_CFG['stock_dec_time'] == SDT_PLACE) {
         change_order_goods_storage($order['order_id'], false, SDT_PLACE);
     }
 }
 /* 退货用户余额、积分、红包 */
 return_user_surplus_integral_bonus($order);
开发者ID:norain2050,项目名称:benhu,代码行数:31,代码来源:order.php

示例2: order_paid

/**
 * 修改订单的支付状态
 *
 * @access  public
 * @param   string  $log_id     支付编号
 * @param   integer $pay_status 状态
 * @param   string  $note       备注
 * @return  void
 */
function order_paid($log_id, $pay_status = PS_PAYED, $note = '')
{
    /* 取得支付编号 */
    $log_id = intval($log_id);
    if ($log_id > 0) {
        /* 取得要修改的支付记录信息 */
        $sql = "SELECT * FROM " . $GLOBALS['hhs']->table('pay_log') . " WHERE log_id = '{$log_id}'";
        $pay_log = $GLOBALS['db']->getRow($sql);
        if ($pay_log && $pay_log['is_paid'] == 0) {
            /* 修改此次支付操作的状态为已付款 */
            $sql = 'UPDATE ' . $GLOBALS['hhs']->table('pay_log') . " SET is_paid = '1' WHERE log_id = '{$log_id}'";
            $GLOBALS['db']->query($sql);
            /* 根据记录类型做相应处理 */
            if ($pay_log['order_type'] == PAY_ORDER) {
                /* 取得订单信息 */
                $sql = 'SELECT order_id, user_id, order_sn, consignee, address, tel, shipping_id, extension_code, extension_id, goods_amount ' . 'FROM ' . $GLOBALS['hhs']->table('order_info') . " WHERE order_id = '{$pay_log['order_id']}'";
                $order = $GLOBALS['db']->getRow($sql);
                $order_id = $order['order_id'];
                $order_sn = $order['order_sn'];
                /* 修改订单状态为已付款 */
                $sql = 'UPDATE ' . $GLOBALS['hhs']->table('order_info') . " SET order_status = '" . OS_CONFIRMED . "', " . " confirm_time = '" . gmtime() . "', " . " pay_status = '{$pay_status}', " . " pay_time = '" . gmtime() . "', " . " money_paid = order_amount," . " order_amount = 0 " . "WHERE order_id = '{$order_id}'";
                $GLOBALS['db']->query($sql);
                /* 记录订单操作记录 */
                order_action($order_sn, OS_CONFIRMED, SS_UNSHIPPED, $pay_status, $note, $GLOBALS['_LANG']['buyer']);
                /* 如果需要,发短信 */
                if ($GLOBALS['_CFG']['sms_order_payed'] == '1' && $GLOBALS['_CFG']['sms_shop_mobile'] != '') {
                    include_once ROOT_PATH . 'includes/cls_sms.php';
                    $sms = new sms();
                    $sms->send($GLOBALS['_CFG']['sms_shop_mobile'], sprintf($GLOBALS['_LANG']['order_payed_sms'], $order_sn, $order['consignee'], $order['tel']), '', 13, 1);
                }
                /* 对虚拟商品的支持 */
                $virtual_goods = get_virtual_goods($order_id);
                if (!empty($virtual_goods)) {
                    $msg = '';
                    if (!virtual_goods_ship($virtual_goods, $msg, $order_sn, true)) {
                        $GLOBALS['_LANG']['pay_success'] .= '<div style="color:red;">' . $msg . '</div>' . $GLOBALS['_LANG']['virtual_goods_ship_fail'];
                    }
                    /* 如果订单没有配送方式,自动完成发货操作 */
                    if ($order['shipping_id'] == -1) {
                        /* 将订单标识为已发货状态,并记录发货记录 */
                        $sql = 'UPDATE ' . $GLOBALS['hhs']->table('order_info') . " SET shipping_status = '" . SS_SHIPPED . "', shipping_time = '" . gmtime() . "'" . " WHERE order_id = '{$order_id}'";
                        $GLOBALS['db']->query($sql);
                        /* 记录订单操作记录 */
                        order_action($order_sn, OS_CONFIRMED, SS_SHIPPED, $pay_status, $note, $GLOBALS['_LANG']['buyer']);
                        $integral = integral_to_give($order);
                        log_account_change($order['user_id'], 0, 0, intval($integral['rank_points']), intval($integral['custom_points']), sprintf($GLOBALS['_LANG']['order_gift_integral'], $order['order_sn']));
                    }
                }
            } elseif ($pay_log['order_type'] == PAY_SURPLUS) {
                $sql = 'SELECT `id` FROM ' . $GLOBALS['hhs']->table('user_account') . " WHERE `id` = '{$pay_log['order_id']}' AND `is_paid` = 1  LIMIT 1";
                $res_id = $GLOBALS['db']->getOne($sql);
                if (empty($res_id)) {
                    /* 更新会员预付款的到款状态 */
                    $sql = 'UPDATE ' . $GLOBALS['hhs']->table('user_account') . " SET paid_time = '" . gmtime() . "', is_paid = 1" . " WHERE id = '{$pay_log['order_id']}' LIMIT 1";
                    $GLOBALS['db']->query($sql);
                    /* 取得添加预付款的用户以及金额 */
                    $sql = "SELECT user_id, amount FROM " . $GLOBALS['hhs']->table('user_account') . " WHERE id = '{$pay_log['order_id']}'";
                    $arr = $GLOBALS['db']->getRow($sql);
                    /* 修改会员帐户金额 */
                    $_LANG = array();
                    include_once ROOT_PATH . 'languages/' . $GLOBALS['_CFG']['lang'] . '/user.php';
                    log_account_change($arr['user_id'], $arr['amount'], 0, 0, 0, $_LANG['surplus_type_0'], ACT_SAVING);
                }
            }
        } else {
            /* 取得已发货的虚拟商品信息 */
            $post_virtual_goods = get_virtual_goods($pay_log['order_id'], true);
            /* 有已发货的虚拟商品 */
            if (!empty($post_virtual_goods)) {
                $msg = '';
                /* 检查两次刷新时间有无超过12小时 */
                $sql = 'SELECT pay_time, order_sn FROM ' . $GLOBALS['hhs']->table('order_info') . " WHERE order_id = '{$pay_log['order_id']}'";
                $row = $GLOBALS['db']->getRow($sql);
                $intval_time = gmtime() - $row['pay_time'];
                if ($intval_time >= 0 && $intval_time < 3600 * 12) {
                    $virtual_card = array();
                    foreach ($post_virtual_goods as $code => $goods_list) {
                        /* 只处理虚拟卡 */
                        if ($code == 'virtual_card') {
                            foreach ($goods_list as $goods) {
                                if ($info = virtual_card_result($row['order_sn'], $goods)) {
                                    $virtual_card[] = array('goods_id' => $goods['goods_id'], 'goods_name' => $goods['goods_name'], 'info' => $info);
                                }
                            }
                            $GLOBALS['smarty']->assign('virtual_card', $virtual_card);
                        }
                    }
                } else {
                    $msg = '<div>' . $GLOBALS['_LANG']['please_view_order_detail'] . '</div>';
                }
                $GLOBALS['_LANG']['pay_success'] .= $msg;
//.........这里部分代码省略.........
开发者ID:shiruolin,项目名称:hzzshop,代码行数:101,代码来源:lib_payment.php

示例3: empty

 empty($affiliate) && ($affiliate = array());
 $separate_by = $affiliate['config']['separate_by'];
 $oid = (int) $_REQUEST['oid'];
 $row = $db->getRow("SELECT o.order_sn, o.is_separate, (o.goods_amount - o.discount) AS goods_amount, o.user_id FROM " . $GLOBALS['ecs']->table('order_info') . " o" . " LEFT JOIN " . $GLOBALS['ecs']->table('users') . " u ON o.user_id = u.user_id" . " WHERE order_id = '{$oid}'");
 $order_sn = $row['order_sn'];
 if (empty($row['is_separate'])) {
     $affiliate['config']['level_point_all'] = (double) $affiliate['config']['level_point_all'];
     $affiliate['config']['level_money_all'] = (double) $affiliate['config']['level_money_all'];
     if ($affiliate['config']['level_point_all']) {
         $affiliate['config']['level_point_all'] /= 100;
     }
     if ($affiliate['config']['level_money_all']) {
         $affiliate['config']['level_money_all'] /= 100;
     }
     $money = round($affiliate['config']['level_money_all'] * $row['goods_amount'], 2);
     $integral = integral_to_give(array('order_id' => $oid, 'extension_code' => ''));
     $point = round($affiliate['config']['level_point_all'] * intval($integral['rank_points']), 0);
     if (empty($separate_by)) {
         //推荐注册分成
         $num = count($affiliate['item']);
         for ($i = 0; $i < $num; $i++) {
             $affiliate['item'][$i]['level_point'] = (double) $affiliate['item'][$i]['level_point'];
             $affiliate['item'][$i]['level_money'] = (double) $affiliate['item'][$i]['level_money'];
             if ($affiliate['item'][$i]['level_point']) {
                 $affiliate['item'][$i]['level_point'] /= 100;
             }
             if ($affiliate['item'][$i]['level_money']) {
                 $affiliate['item'][$i]['level_money'] /= 100;
             }
             $setmoney = round($money * $affiliate['item'][$i]['level_money'], 2);
             $setpoint = round($point * $affiliate['item'][$i]['level_point'], 0);
开发者ID:jinjing1989,项目名称:wei,代码行数:31,代码来源:affiliate_ck.php

示例4: cancel_delivery

function cancel_delivery($order_id, $delivery_id)
{
    global $db, $ecs;
    /* 取得参数 */
    $delivery = '';
    /* 根据发货单id查询发货单信息 */
    if (!empty($delivery_id)) {
        $delivery_order = delivery_order_info($delivery_id);
    } else {
        sys_msg('订单号不能为空!', 1);
    }
    /* 查询订单信息 */
    $order = order_info($order_id);
    /* 取消当前发货单物流单号 */
    $_delivery['invoice_no'] = '';
    $_delivery['status'] = 2;
    $query = $db->autoExecute($ecs->table('delivery_order'), $_delivery, 'UPDATE', "delivery_id = {$delivery_id}", 'SILENT');
    if (!$query) {
        /* 操作失败 */
        $links[] = array('text' => $GLOBALS['_LANG']['delivery_sn'] . $GLOBALS['_LANG']['detail'], 'href' => 'order.php?act=delivery_info&delivery_id=' . $delivery_id);
        sys_msg($GLOBALS['_LANG']['act_false'], 1, $links);
        exit;
    }
    /* 修改定单发货单号 */
    $invoice_no_order = explode('<br>', $order['invoice_no']);
    $invoice_no_delivery = explode('<br>', $delivery_order['invoice_no']);
    foreach ($invoice_no_order as $key => $value) {
        $delivery_key = array_search($value, $invoice_no_delivery);
        if ($delivery_key !== false) {
            unset($invoice_no_order[$key], $invoice_no_delivery[$delivery_key]);
            if (count($invoice_no_delivery) == 0) {
                break;
            }
        }
    }
    $_order['invoice_no'] = implode('<br>', $invoice_no_order);
    /* 更新配送状态 */
    $order_finish = get_all_delivery_finish($order_id);
    $shipping_status = $order_finish == -1 ? SS_SHIPPED_PART : SS_SHIPPED_ING;
    $arr['shipping_status'] = $shipping_status;
    if ($shipping_status == SS_SHIPPED_ING) {
        $arr['shipping_time'] = '';
        // 发货时间
    }
    $arr['invoice_no'] = $_order['invoice_no'];
    update_order($order_id, $arr);
    /* 发货单取消发货记录log */
    order_action($order['order_sn'], $order['order_status'], $shipping_status, $order['pay_status'], $action_note, null, 1);
    /* 如果使用库存,则增加库存 */
    if ($_CFG['use_storage'] == '1' && $_CFG['stock_dec_time'] == SDT_SHIP) {
        // 检查此单发货商品数量
        $virtual_goods = array();
        $delivery_stock_sql = "SELECT DG.goods_id, DG.product_id, DG.is_real, SUM(DG.send_number) AS sums\r\n            FROM " . $GLOBALS['ecs']->table('delivery_goods') . " AS DG\r\n            WHERE DG.delivery_id = '{$delivery_id}'\r\n            GROUP BY DG.goods_id ";
        $delivery_stock_result = $GLOBALS['db']->getAll($delivery_stock_sql);
        foreach ($delivery_stock_result as $key => $value) {
            /* 虚拟商品 */
            if ($value['is_real'] == 0) {
                continue;
            }
            //(货品)
            if (!empty($value['product_id'])) {
                $minus_stock_sql = "UPDATE " . $GLOBALS['ecs']->table('products') . "\r\n                                    SET product_number = product_number + " . $value['sums'] . "\r\n                                    WHERE product_id = " . $value['product_id'];
                $GLOBALS['db']->query($minus_stock_sql, 'SILENT');
            }
            $minus_stock_sql = "UPDATE " . $GLOBALS['ecs']->table('goods') . "\r\n                                SET goods_number = goods_number + " . $value['sums'] . "\r\n                                WHERE goods_id = " . $value['goods_id'];
            $GLOBALS['db']->query($minus_stock_sql, 'SILENT');
        }
    }
    /* 发货单全退回时,退回其它 */
    if ($order['order_status'] == SS_SHIPPED_ING) {
        /* 如果订单用户不为空,计算积分,并退回 */
        if ($order['user_id'] > 0) {
            /* 取得用户信息 */
            $user = user_info($order['user_id']);
            /* 计算并退回积分 */
            $integral = integral_to_give($order);
            log_account_change($order['user_id'], 0, 0, -1 * intval($integral['rank_points']), -1 * intval($integral['custom_points']), sprintf($GLOBALS['_LANG']['return_order_gift_integral'], $order['order_sn']));
            /* todo 计算并退回红包 */
            return_order_bonus($order_id);
        }
    }
    /* 清除缓存 */
    clear_cache_files();
    /* 操作成功 */
    $links[] = array('text' => $GLOBALS['_LANG']['delivery_sn'] . $GLOBALS['_LANG']['detail'], 'href' => 'order.php?act=delivery_info&delivery_id=' . $delivery_id);
    sys_msg($GLOBALS['_LANG']['act_ok'], 0, $links);
}
开发者ID:seanguo166,项目名称:yinoos,代码行数:87,代码来源:order.php

示例5: done


//.........这里部分代码省略.........
	               " WHERE is_real = 0 AND extension_code = 'virtual_card'".
	               " AND session_id = '".SESS_ID."' AND rec_type = '$flow_type'";
	
	        $res = $GLOBALS['db']->getAll($sql);
	error_log('4',3,'flow.log');
	        $virtual_goods = array();
	        foreach ($res AS $row)
	        {
	            $virtual_goods['virtual_card'][] = array('goods_id' => $row['goods_id'], 'goods_name' => $row['goods_name'], 'num' => $row['num']);
	        }
	
	        if ($virtual_goods AND $flow_type != CART_GROUP_BUY_GOODS)
	        {
	            /* 虚拟卡发货 */
	            if (virtual_goods_ship($virtual_goods,$msg, $order['order_sn'], true))
	            {
	                /* 如果没有实体商品,修改发货状态,送积分和红包 */
	                $sql = "SELECT COUNT(*)" .
	                        " FROM " . $ecs->table('order_goods') .
	                        " WHERE order_id = '$order[order_id]' " .
	                        " AND is_real = 1";
	                if ($db->getOne($sql) <= 0)
	                {
	                    /* 修改订单状态 */
	                    update_order($order['order_id'], array('shipping_status' => SS_SHIPPED, 'shipping_time' => gmtime()));
	error_log('5',3,'flow.log');
	                    /* 如果订单用户不为空,计算积分,并发给用户;发红包 */
	                    if ($order['user_id'] > 0)
	                    {
	                        /* 取得用户信息 */
	                        $user = user_info($order['user_id']);
	
	                        /* 计算并发放积分 */
	                        $integral = integral_to_give($order);
	                        log_account_change($order['user_id'], 0, 0, intval($integral['rank_points']), intval($integral['custom_points']), sprintf($_LANG['order_gift_integral'], $order['order_sn']));
	error_log('6',3,'flow.log');
	                        /* 发放红包 */
	                        send_order_bonus($order['order_id']);
	                    }
	                }
	            }
	        }
	
	    }
	
	    /* 清空购物车 */
	    clear_cart($flow_type);
	error_log('7',3,'flow.log');
	    /* 清除缓存,否则买了商品,但是前台页面读取缓存,商品数量不减少 */
	    clear_all_files();
	
	    /* 插入支付日志 */
	    //$order['log_id'] = insert_pay_log($new_order_id, $order['order_amount'], PAY_ORDER);
	
	   error_log('8',3,'flow.log'); 
		
		/*取得支付代码
	
		#取得支付信息,生成支付代码 
	    if ($order['order_amount'] > 0)
	    {
	        $payment = payment_info($order['pay_id']);
	
	        include_once('includes/modules/payment/' . $payment['pay_code'] . '.php');
	
	        $pay_obj    = new $payment['pay_code'];
开发者ID:noikiy,项目名称:mdwp,代码行数:67,代码来源:flow.action.php

示例6: cancel_delivery

function cancel_delivery($order_id, $delivery_id)
{
    global $db, $ecs, $_CFG;
    /* 取得参数 */
    $delivery = '';
    /* 根据发货单id查询发货单信息 */
    if (!empty($delivery_id)) {
        $delivery_order = delivery_order_info($delivery_id);
    } else {
        sys_msg('订单号不能为空!', 1);
    }
    /* 查询订单信息 */
    $order = order_info($order_id);
    /* 取消当前发货单物流单号 */
    $_delivery['invoice_no'] = '';
    $_delivery['status'] = 2;
    $query = $db->autoExecute($ecs->table('delivery_order'), $_delivery, 'UPDATE', "delivery_id = {$delivery_id}", 'SILENT');
    if (!$query) {
        /* 操作失败 */
        $links[] = array('text' => $GLOBALS['_LANG']['delivery_sn'] . $GLOBALS['_LANG']['detail'], 'href' => 'order.php?act=delivery_info&delivery_id=' . $delivery_id);
        sys_msg($GLOBALS['_LANG']['act_false'], 1, $links);
        exit;
    }
    /* 修改定单发货单号 */
    $invoice_no_order = explode('<br>', $order['invoice_no']);
    $invoice_no_delivery = explode('<br>', $delivery_order['invoice_no']);
    foreach ($invoice_no_order as $key => $value) {
        $delivery_key = array_search($value, $invoice_no_delivery);
        if ($delivery_key !== false) {
            unset($invoice_no_order[$key], $invoice_no_delivery[$delivery_key]);
            if (count($invoice_no_delivery) == 0) {
                break;
            }
        }
    }
    $_order['invoice_no'] = implode('<br>', $invoice_no_order);
    /* 更新配送状态 */
    $order_finish = get_all_delivery_finish($order_id);
    $shipping_status = $order_finish == -1 ? SS_SHIPPED_PART : SS_SHIPPED_ING;
    $arr['shipping_status'] = $shipping_status;
    if ($shipping_status == SS_SHIPPED_ING) {
        $arr['shipping_time'] = '';
        // 发货时间
    }
    $arr['invoice_no'] = $_order['invoice_no'];
    update_order($order_id, $arr);
    /* 发货单取消发货记录log */
    order_action($order['order_sn'], $order['order_status'], $shipping_status, $order['pay_status'], $action_note, null, 1);
    /* 如果使用库存,则增加库存 */
    /* 代码增加_start   By  morestock_morecity  */
    if ($_CFG['use_storage'] == '1' && $_CFG['stock_dec_time'] == SDT_SHIP) {
        $delivery_stock_sql = "SELECT * FROM " . $GLOBALS['ecs']->table('delivery_goods') . " WHERE delivery_id = '{$delivery_id}' ";
        $delivery_stock_result = $GLOBALS['db']->getAll($delivery_stock_sql);
        $store_error = '';
        //$goods_attr_id = get_goods_attr_id($value['goods_id'], $value['goods_attr']);
        $store_id_zhyh = get_storeid_by_ssq($order['province'], $order['city'], $order['district'], $order['xiangcun'], $order['supplier_id']);
        if (!$store_id_zhyh) {
            $store_error = '该发货单没有对应仓库!';
        }
        if ($store_error) {
            sys_msg($store_error);
        } else {
            foreach ($delivery_stock_result as $key => $value) {
                $goods_attr_id = get_goods_attr_id($value['goods_id'], $value['goods_attr']);
                $store_row = get_storeid_youhuo($order['province'], $order['city'], $order['district'], $order['xiangcun'], $value['goods_id'], $goods_attr_id, $order['supplier_id'], $order_id);
                $add_time = gmtime();
                $add_date = local_date('Ymd');
                $sql = "select max(today_sn) from " . $ecs->table('store_inout_list') . " where inout_mode=2 and  add_date='{$add_date}' ";
                $inout_count = $db->getOne($sql);
                $inout_sn = $inout_count ? intval($inout_count + 1) : 1;
                $today_sn = $inout_sn;
                $inout_sn = str_pad($inout_sn, 4, "0", STR_PAD_LEFT);
                $inout_sn = 'rk' . $add_date . $inout_sn;
                $stock_type_id = 0;
                if ($order['supplier_id'] > 0) {
                    $stock_type_id = $db->getOne('select type from ' . $ecs->table('store_type') . " where supplier_id=" . $order['supplier_id']);
                }
                $sql = "insert into " . $ecs->table('store_inout_list') . "(inout_sn, inout_status, store_id, adminer_id, inout_type, inout_mode, order_sn, " . "takegoods_man, today_sn, add_date, add_time, supplier_id, store_type_id)  " . "values('{$inout_sn}', '3', '{$store_row['store_id']}', '{$_SESSION['supplier_user_id']}', '5', '2', '{$order['order_sn']}', " . "'{$_SESSION['supplier_name']}', '{$today_sn}' , '{$add_date}', '{$add_time}','{$order['supplier_id']}', '{$stock_type_id}' ) ";
                $db->query($sql);
                $inout_rec_id = $db->insert_id();
                $sql = "insert into " . $ecs->table('store_inout_goods') . "(inout_rec_id, goods_id, goods_sn, attr_value, inout_mode, number_yingshou, number_shishou, supplier_id, store_type_id)  " . "values('{$inout_rec_id}', '{$value['goods_id']}', '{$value['goods_sn']}', '{$goods_attr_id}', '2', '{$value['send_number']}', '{$value['send_number']}','{$order['supplier_id']}', '{$stock_type_id}') ";
                $db->query($sql);
                $upre = update_stock_in($inout_rec_id, $store_row['store_id']);
                //更新库存表
            }
        }
    }
    /* 代码增加_end   By  morestock_morecity  */
    /* 发货单全退回时,退回其它 */
    if ($order['order_status'] == SS_SHIPPED_ING) {
        /* 如果订单用户不为空,计算积分,并退回 */
        if ($order['user_id'] > 0) {
            /* 取得用户信息 */
            $user = user_info($order['user_id']);
            /* 计算并退回积分 */
            $integral = integral_to_give($order);
            log_account_change($order['user_id'], 0, 0, -1 * intval($integral['rank_points']), -1 * intval($integral['custom_points']), sprintf($GLOBALS['_LANG']['return_order_gift_integral'], $order['order_sn']));
            /* todo 计算并退回红包 */
            return_order_bonus($order_id);
        }
//.........这里部分代码省略.........
开发者ID:moonlight-wang,项目名称:feilun,代码行数:101,代码来源:order.php

示例7: order_paid

/**
 * 修改订单的支付状态
 *
 * @access  public
 * @param   string  $log_id     支付编号
 * @param   integer $pay_status 状态
 * @param   string  $note       备注
 * @return  void
 */
function order_paid($log_id, $pay_status = PS_PAYED, $note = '')
{
    /* 取得支付编号 */
    $log_id = intval($log_id);
    if ($log_id > 0) {
        /* 取得要修改的支付记录信息 */
        $sql = "SELECT * FROM " . $GLOBALS['ecs']->table('pay_log') . " WHERE log_id = '{$log_id}'";
        $pay_log = $GLOBALS['db']->getRow($sql);
        if (!empty($pay_log) && $pay_log['is_paid'] == 0) {
            /* 修改此次支付操作的状态为已付款 */
            $sql = 'UPDATE ' . $GLOBALS['ecs']->table('pay_log') . " SET is_paid = '1' WHERE log_id = '{$log_id}'";
            $GLOBALS['db']->query($sql);
            /* 根据记录类型做相应处理 */
            if ($pay_log['order_type'] == PAY_ORDER) {
                /* 取得订单信息 */
                $sql = 'SELECT order_id, user_id, order_sn, consignee, address, tel, shipping_id, extension_code, extension_id, goods_amount ' . 'FROM ' . $GLOBALS['ecs']->table('order_info') . " WHERE order_id = '{$pay_log['order_id']}'";
                $order = $GLOBALS['db']->getRow($sql);
                $order_id = $order['order_id'];
                $order_sn = $order['order_sn'];
                /* 修改订单状态为已付款 */
                $sql = 'UPDATE ' . $GLOBALS['ecs']->table('order_info') . " SET pay_status = '{$pay_status}', " . " pay_time = '" . gmtime() . "', " . " money_paid = order_amount," . " order_amount = 0 " . "WHERE order_id = '{$order_id}'";
                $GLOBALS['db']->query($sql);
                /* 记录订单操作记录 */
                order_action($order_sn, OS_UNCONFIRMED, SS_UNSHIPPED, $pay_status, $note, $GLOBALS['_LANG']['buyer']);
                /* 如果需要,发短信 */
                /*if ($GLOBALS['_CFG']['sms_order_payed'] == '1' && $GLOBALS['_CFG']['sms_shop_mobile'] != '')
                             {
                                 include_once(ROOT_PATH.'include/cls_sms.php');
                                 $sms = new sms();
                   		$sms_error = array();
                                 if(!$sms->send($GLOBALS['_CFG']['sms_shop_mobile'], sprintf($GLOBALS['_LANG']['order_payed_sms'], $order_sn, $order['consignee'], $order['tel']), $sms_error)){
                			echo $sms_error;
                		}
                             }*/
                // 检查限时抢购促销数量
                $sql = "select f.id, f.promote_num, sum(b.goods_number) AS sale_num FROM " . $GLOBALS['ecs']->table('order_goods', 'a') . "," . $GLOBALS['ecs']->table('order_goods', 'b') . "," . $GLOBALS['ecs']->table('order_info', 'o') . "," . $GLOBALS['ecs']->table('flash_sale', 'f') . " WHERE a.extension_code = b.extension_code AND a.extension_id = b.extension_id AND f.id = a.extension_id AND " . " o.order_id = b.order_id AND o.pay_status = " . PS_PAYED . " AND a.extension_code = 'flash_sale' AND a.order_id = '{$order_id}' " . " GROUP BY a.extension_id";
                $result = $GLOBALS['db']->getAll($sql);
                if (!empty($result)) {
                    foreach ($result as $flash) {
                        if ($flash['promote_num'] > 0 && $flash['promote_num'] <= $flash['sale_num']) {
                            $sql = "UPDATE " . $GLOBALS['ecs']->table('flash_sale') . " SET is_on_sale = 0 WHERE id = '{$flash['id']}'";
                            $GLOBALS['db']->query($sql);
                        }
                    }
                }
                /* 对虚拟商品的支持 */
                $virtual_goods = get_virtual_goods($order_id);
                if (!empty($virtual_goods)) {
                    $msg = '';
                    if (!virtual_goods_ship($virtual_goods, $msg, $order_sn, true)) {
                        $GLOBALS['_LANG']['pay_success'] .= '<div style="color:red;">' . $msg . '</div>' . $GLOBALS['_LANG']['virtual_goods_ship_fail'];
                    }
                    /* 如果订单没有配送方式,自动完成发货操作 */
                    if ($order['shipping_id'] == -1) {
                        /* 将订单标识为已发货状态,并记录发货记录 */
                        $sql = 'UPDATE ' . $GLOBALS['ecs']->table('order_info') . " SET shipping_status = '" . SS_SHIPPED . "', shipping_time = '" . gmtime() . "'" . " WHERE order_id = '{$order_id}'";
                        $GLOBALS['db']->query($sql);
                        /* 记录订单操作记录 */
                        order_action($order_sn, OS_CONFIRMED, SS_SHIPPED, $pay_status, $note, $GLOBALS['_LANG']['buyer']);
                        $integral = integral_to_give($order);
                        log_account_change($order['user_id'], 0, 0, intval($integral['rank_points']), intval($integral['custom_points']), sprintf($GLOBALS['_LANG']['order_gift_integral'], $order['order_sn']));
                    }
                }
            } elseif ($pay_log['order_type'] == PAY_SURPLUS) {
                $sql = 'SELECT `id` FROM ' . $GLOBALS['ecs']->table('user_account') . " WHERE `id` = '{$pay_log['order_id']}' AND `is_paid` = 1  LIMIT 1";
                $res_id = $GLOBALS['db']->getOne($sql);
                if (empty($res_id)) {
                    /* 更新会员预付款的到款状态 */
                    $sql = 'UPDATE ' . $GLOBALS['ecs']->table('user_account') . " SET paid_time = '" . gmtime() . "', is_paid = 1" . " WHERE id = '{$pay_log['order_id']}' LIMIT 1";
                    $GLOBALS['db']->query($sql);
                    /* 取得添加预付款的用户以及金额 */
                    $sql = "SELECT user_id, amount FROM " . $GLOBALS['ecs']->table('user_account') . " WHERE id = '{$pay_log['order_id']}'";
                    $arr = $GLOBALS['db']->getRow($sql);
                    /* 修改会员帐户金额 */
                    $_LANG = array();
                    include_once ROOT_PATH . 'lang/' . $GLOBALS['_CFG']['lang'] . '/user.php';
                    log_account_change($arr['user_id'], $arr['amount'], 0, 0, 0, $_LANG['surplus_type_0'], ACT_SAVING);
                }
            }
        }
    }
}
开发者ID:GYWang1983,项目名称:fruit,代码行数:91,代码来源:lib_payment.php

示例8: affiliate_separate

function affiliate_separate($db, $row, $oid, $affiliate, $separate_by)
{
    $order_sn = $row['order_sn'];
    if (empty($row['is_separate'])) {
        $affiliate['config']['level_point_all'] = (double) $affiliate['config']['level_point_all'];
        $affiliate['config']['level_money_all'] = (double) $affiliate['config']['level_money_all'];
        if ($affiliate['config']['level_point_all']) {
            $affiliate['config']['level_point_all'] /= 100;
        }
        if ($affiliate['config']['level_money_all']) {
            $affiliate['config']['level_money_all'] /= 100;
        }
        $money = round($affiliate['config']['level_money_all'] * $row['goods_amount'], 2);
        $integral = integral_to_give(array('order_id' => $oid, 'extension_code' => ''));
        $point = round($affiliate['config']['level_point_all'] * intval($integral['rank_points']), 0);
        if (empty($separate_by)) {
            // 推荐注册分成
            $num = count($affiliate['item']);
            for ($i = 0; $i < $num; $i++) {
                $affiliate['item'][$i]['level_point'] = (double) $affiliate['item'][$i]['level_point'];
                $affiliate['item'][$i]['level_money'] = (double) $affiliate['item'][$i]['level_money'];
                if ($affiliate['item'][$i]['level_point']) {
                    $affiliate['item'][$i]['level_point'] /= 100;
                }
                if ($affiliate['item'][$i]['level_money']) {
                    $affiliate['item'][$i]['level_money'] /= 100;
                }
                $setmoney = round($money * $affiliate['item'][$i]['level_money'], 2);
                $setpoint = round($point * $affiliate['item'][$i]['level_point'], 0);
                $row = $db->getRow("SELECT o.parent_id as user_id,u.user_name FROM " . $GLOBALS['ecs']->table('users') . " o" . " LEFT JOIN" . $GLOBALS['ecs']->table('users') . " u ON o.parent_id = u.user_id" . " WHERE o.user_id = '{$row['user_id']}'");
                $up_uid = $row['user_id'];
                if (empty($up_uid) || empty($row['user_name'])) {
                    break;
                } else {
                    $info = sprintf($_LANG['separate_info'], $order_sn, $setmoney, $setpoint);
                    log_account_change($up_uid, $setmoney, 0, $setpoint, 0, $info);
                    write_affiliate_log($oid, $up_uid, $row['user_name'], $setmoney, $setpoint, $separate_by);
                }
            }
        } else {
            // 推荐订单分成
            $row = $db->getRow("SELECT o.parent_id, u.user_name FROM " . $GLOBALS['ecs']->table('order_info') . " o" . " LEFT JOIN" . $GLOBALS['ecs']->table('users') . " u ON o.parent_id = u.user_id" . " WHERE o.order_id = '{$oid}'");
            $up_uid = $row['parent_id'];
            if (!empty($up_uid) && $up_uid > 0) {
                $info = sprintf($_LANG['separate_info'], $order_sn, $money, $point);
                log_account_change($up_uid, $money, 0, $point, 0, $info);
                write_affiliate_log($oid, $up_uid, $row['user_name'], $money, $point, $separate_by);
            } else {
                $links[] = array('text' => $_LANG['affiliate_ck'], 'href' => 'affiliate_ck.php?act=list');
                sys_msg($_LANG['edit_fail'], 1, $links);
            }
        }
        $sql = "UPDATE " . $GLOBALS['ecs']->table('order_info') . " SET is_separate = 1" . " WHERE order_id = '{$oid}'";
        $db->query($sql);
    }
}
开发者ID:a494008974,项目名称:bzbshop,代码行数:56,代码来源:affiliate_ck.php


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