Ejemplo n.º 1
0
function refund_confirm_order_goods($rec_id, $refund_status)
{
    $row = $GLOBALS['db']->getRow("select og.rec_id,o.user_id,og.goods_price*og.goods_number as refund_money,o.order_sn,og.goods_number,og.goods_name from " . $GLOBALS['hhs']->table("order_goods") . " as og," . $GLOBALS['hhs']->table("order_info") . " as o  where o.order_id=og.order_id and refund_status='1' and rec_id='{$rec_id}'");
    empty($row) ? die("inalid") : extract($row);
    if ($rec_id > 0) {
        if ($refund_status == 2) {
            $change_desc = "订单{$order_sn}中的{$goods_name}退款成功,返还余额";
            log_account_change($user_id, $refund_money, 0, 0, 0, $change_desc, ACT_OTHER);
        }
        $GLOBALS['db']->query("update " . $GLOBALS['hhs']->table("order_goods") . " set refund_status='{$refund_status}',refund_confirm_time='" . gmtime() . "' where rec_id='{$rec_id}'");
    }
}
Ejemplo n.º 2
0
function action_insert()
{
    // 全局变量
    $user = $GLOBALS['user'];
    $_CFG = $GLOBALS['_CFG'];
    $_LANG = $GLOBALS['_LANG'];
    $smarty = $GLOBALS['smarty'];
    $db = $GLOBALS['db'];
    $ecs = $GLOBALS['ecs'];
    $user_id = $_SESSION['user_id'];
    /* 检查权限 */
    admin_priv('users_manage');
    $username = empty($_POST['username']) ? '' : trim($_POST['username']);
    $password = empty($_POST['password']) ? '' : trim($_POST['password']);
    $email = empty($_POST['email']) ? '' : trim($_POST['email']);
    $sex = empty($_POST['sex']) ? 0 : intval($_POST['sex']);
    $sex = in_array($sex, array(0, 1, 2)) ? $sex : 0;
    $birthday = $_POST['birthdayYear'] . '-' . $_POST['birthdayMonth'] . '-' . $_POST['birthdayDay'];
    $rank = empty($_POST['user_rank']) ? 0 : intval($_POST['user_rank']);
    $credit_line = empty($_POST['credit_line']) ? 0 : floatval($_POST['credit_line']);
    /* 代码增加2014-12-23 by www.68ecshop.com _star */
    $real_name = empty($_POST['real_name']) ? '' : trim($_POST['real_name']);
    $card = empty($_POST['card']) ? '' : trim($_POST['card']);
    $country = $_POST['country'];
    $province = $_POST['province'];
    $city = $_POST['city'];
    $district = $_POST['district'];
    $address = empty($_POST['address']) ? '' : trim($_POST['address']);
    $status = $_POST['status'];
    /* 代码增加2014-12-23 by www.68ecshop.com _end */
    $users =& init_users();
    if (!$users->add_user($username, $password, $email)) {
        /* 插入会员数据失败 */
        if ($users->error == ERR_INVALID_USERNAME) {
            $msg = $_LANG['username_invalid'];
        } elseif ($users->error == ERR_USERNAME_NOT_ALLOW) {
            $msg = $_LANG['username_not_allow'];
        } elseif ($users->error == ERR_USERNAME_EXISTS) {
            $msg = $_LANG['username_exists'];
        } elseif ($users->error == ERR_INVALID_EMAIL) {
            $msg = $_LANG['email_invalid'];
        } elseif ($users->error == ERR_EMAIL_NOT_ALLOW) {
            $msg = $_LANG['email_not_allow'];
        } elseif ($users->error == ERR_EMAIL_EXISTS) {
            $msg = $_LANG['email_exists'];
        } else {
            // die('Error:'.$users->error_msg());
        }
        sys_msg($msg, 1);
    }
    /* 注册送积分 */
    if (!empty($GLOBALS['_CFG']['register_points'])) {
        log_account_change($_SESSION['user_id'], 0, 0, $GLOBALS['_CFG']['register_points'], $GLOBALS['_CFG']['register_points'], $_LANG['register_points']);
    }
    /* 把新注册用户的扩展信息插入数据库 */
    $sql = 'SELECT id FROM ' . $ecs->table('reg_fields') . ' WHERE type = 0 AND display = 1 ORDER BY dis_order, id';
    // 读出所有扩展字段的id
    $fields_arr = $db->getAll($sql);
    $extend_field_str = '';
    // 生成扩展字段的内容字符串
    $user_id_arr = $users->get_profile_by_name($username);
    foreach ($fields_arr as $val) {
        $extend_field_index = 'extend_field' . $val['id'];
        if (!empty($_POST[$extend_field_index])) {
            $temp_field_content = strlen($_POST[$extend_field_index]) > 100 ? mb_substr($_POST[$extend_field_index], 0, 99) : $_POST[$extend_field_index];
            $extend_field_str .= " ('" . $user_id_arr['user_id'] . "', '" . $val['id'] . "', '" . $temp_field_content . "'),";
        }
    }
    $extend_field_str = substr($extend_field_str, 0, -1);
    if ($extend_field_str) {
        $sql = 'INSERT INTO ' . $ecs->table('reg_extend_info') . ' (`user_id`, `reg_field_id`, `content`) VALUES' . $extend_field_str;
        $db->query($sql);
    }
    /* 更新会员的其它信息 */
    $other = array();
    $other['credit_line'] = $credit_line;
    $other['user_rank'] = $rank;
    $other['sex'] = $sex;
    $other['birthday'] = $birthday;
    $other['reg_time'] = local_strtotime(local_date('Y-m-d H:i:s'));
    $other['msn'] = isset($_POST['extend_field1']) ? htmlspecialchars(trim($_POST['extend_field1'])) : '';
    $other['qq'] = isset($_POST['extend_field2']) ? htmlspecialchars(trim($_POST['extend_field2'])) : '';
    $other['office_phone'] = isset($_POST['extend_field3']) ? htmlspecialchars(trim($_POST['extend_field3'])) : '';
    $other['home_phone'] = isset($_POST['extend_field4']) ? htmlspecialchars(trim($_POST['extend_field4'])) : '';
    $other['mobile_phone'] = isset($_POST['extend_field5']) ? htmlspecialchars(trim($_POST['extend_field5'])) : '';
    $db->autoExecute($ecs->table('users'), $other, 'UPDATE', "user_name = '{$username}'");
    /* 代码增加2014-12-23 by www.68ecshop.com _star */
    if (isset($_FILES['face_card']) && $_FILES['face_card']['tmp_name'] != '') {
        $face_card = $image->upload_image($_FILES['face_card']);
        if ($face_card === false) {
            sys_msg($image->error_msg(), 1, array(), false);
        }
    }
    if (isset($_FILES['back_card']) && $_FILES['back_card']['tmp_name'] != '') {
        $back_card = $image->upload_image($_FILES['back_card']);
        if ($back_card === false) {
            sys_msg($image->error_msg(), 1, array(), false);
        }
    }
    $sql = "update " . $ecs->table('users') . " set `real_name`='{$real_name}',`card`='{$card}',`country`='{$country}',`province`='{$province}',`city`='{$city}',`district`='{$district}',`address`='{$address}',`status`='{$status}' where user_name = '" . $username . "'";
    $db->query($sql);
    if ($face_card != '') {
        $sql = "update " . $ecs->table('users') . " set `face_card` = '{$face_card}' where user_name = '" . $username . "'";
        $db->query($sql);
    }
    if ($back_card != '') {
        $sql = "update " . $ecs->table('users') . " set `back_card` = '{$back_card}' where user_name = '" . $username . "'";
        $db->query($sql);
    }
    /* 代码增加2014-12-23 by www.68ecshop.com _end */
    /* 记录管理员操作 */
    admin_log($_POST['username'], 'add', 'users');
    /* 提示信息 */
    $link[] = array('text' => $_LANG['go_back'], 'href' => 'users.php?act=list');
    sys_msg(sprintf($_LANG['add_success'], htmlspecialchars(stripslashes($_POST['username']))), 0, $link);
}
Ejemplo n.º 3
0
         case TO_R:
             $result_points = floor($num * $to / $from);
             $user->set_points($row['user_name'], array($bbs_key => 0 - $num));
             //调整论坛积分
             log_account_change($row['user_id'], 0, 0, $result_points, 0, $_LANG['transform_points'], ACT_OTHER);
             show_message(sprintf($_LANG['to_rank_points'], $num, $points_name[$bbs_key]['title'], $result_points), $_LANG['transform_points'], 'user.php?act=transform_points');
         case FROM_P:
             $result_points = floor($num * $to / $from);
             log_account_change($row['user_id'], 0, 0, 0, 0 - $num, $_LANG['transform_points'], ACT_OTHER);
             //调整商城积分
             $user->set_points($row['user_name'], array($bbs_key => $result_points));
             //调整论坛积分
             show_message(sprintf($_LANG['from_pay_points'], $num, $result_points, $points_name[$bbs_key]['title']), $_LANG['transform_points'], 'user.php?act=transform_points');
         case FROM_R:
             $result_points = floor($num * $to / $from);
             log_account_change($row['user_id'], 0, 0, 0 - $num, 0, $_LANG['transform_points'], ACT_OTHER);
             //调整商城积分
             $user->set_points($row['user_name'], array($bbs_key => $result_points));
             //调整论坛积分
             show_message(sprintf($_LANG['from_rank_points'], $num, $result_points, $points_name[$bbs_key]['title']), $_LANG['transform_points'], 'user.php?act=transform_points');
     }
 } elseif ($action == 'act_transform_ucenter_points') {
     $rule = array();
     if ($_CFG['points_rule']) {
         $rule = unserialize($_CFG['points_rule']);
     }
     $shop_points = array(0 => 'rank_points', 1 => 'pay_points');
     $sql = "SELECT user_id, user_name, pay_points, rank_points FROM " . $ecs->table('users') . " WHERE user_id='{$user_id}'";
     $row = $db->getRow($sql);
     $exchange_amount = intval($_POST['amount']);
     $fromcredits = intval($_POST['fromcredits']);
Ejemplo n.º 4
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)
{
    /* 检查参数 */
    $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);
        $GLOBALS['db']->autoExecute($GLOBALS['ecs']->table('user_account'), $account, 'INSERT');
        return true;
    } else {
        return true;
    }
}
Ejemplo n.º 5
0
/**
 * 退回余额、积分、红包(取消、无效、退货时),把订单使用余额、积分、红包设为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']));
        $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);
}
Ejemplo n.º 6
0
                $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);
    }
    $links[] = array('text' => $_LANG['affiliate_ck'], 'href' => 'affiliate_ck.php?act=list');
    sys_msg($_LANG['edit_ok'], 0, $links);
}
function get_affiliate_ck()
{
    $affiliate = unserialize($GLOBALS['_CFG']['affiliate']);
Ejemplo n.º 7
0
/**
 * 修改订单的支付状态
 *
 * @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 ($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, order_sn, consignee, address, tel, shipping_id ' . '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 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']), 0);
                }
                /* 对虚拟商品的支持 */
                $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']);
                    }
                }
            } elseif ($pay_log['order_type'] == PAY_SURPLUS) {
                /* 更新会员预付款的到款状态 */
                $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 . '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['ecs']->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;
            }
            /* 取得未发货虚拟商品 */
            $virtual_goods = get_virtual_goods($pay_log['order_id'], false);
            if (!empty($virtual_goods)) {
                $GLOBALS['_LANG']['pay_success'] .= '<br />' . $GLOBALS['_LANG']['virtual_goods_ship_fail'];
            }
        }
    }
}
Ejemplo n.º 8
0
        if ($is_paid == '1' && $account['process_type'] == '1') {
            $user_account = get_user_surplus($account['user_id']);
            $fmt_amount = str_replace('-', '', $amount);
            //如果扣除的余额多于此会员拥有的余额,提示
            if ($fmt_amount > $user_account) {
                $link[] = array('text' => $_LANG['go_back'], 'href' => 'javascript:history.back(-1)');
                sys_msg($_LANG['surplus_amount_error'], 0, $link);
            }
            update_user_account($id, $amount, $admin_note, $is_paid);
            //更新会员余额数量
            log_account_change($account['user_id'], $amount, 0, 0, 0, $_LANG['surplus_type_1'], ACT_DRAWING);
        } elseif ($is_paid == '1' && $account['process_type'] == '0') {
            //如果是预付款,并且已完成, 更新此条记录,增加相应的余额
            update_user_account($id, $amount, $admin_note, $is_paid);
            //更新会员余额数量
            log_account_change($account['user_id'], $amount, 0, 0, 0, $_LANG['surplus_type_0'], ACT_SAVING);
        } elseif ($is_paid == '0') {
            /* 否则更新信息 */
            $sql = "UPDATE " . $ecs->table('user_account') . " SET " . "admin_user    = '******'admin_name']}', " . "admin_note    = '{$admin_note}', " . "is_paid       = 0 WHERE id = '{$id}'";
            $db->query($sql);
        }
        /* 记录管理员日志 */
        admin_log('(' . addslashes($_LANG['check']) . ')' . $admin_note, 'edit', 'user_surplus');
        /* 提示信息 */
        $link[0]['text'] = $_LANG['back_list'];
        $link[0]['href'] = 'user_account.php?act=list&' . list_link_postfix();
        sys_msg($_LANG['attradd_succed'], 0, $link);
    }
} elseif ($_REQUEST['act'] == 'query') {
    $list = account_list();
    $smarty->assign('list', $list['list']);
Ejemplo n.º 9
0
	public function done () {
		global $ecs,$db,$_CFG;
		include_once(RPC_ROOT.'includes/lib_clips_ec.php');
	    include_once(RPC_ROOT.'includes/lib_payment.php');
	
	    /* 取得购物类型 */
	    $flow_type = isset($_SESSION['flow_type']) ? intval($_SESSION['flow_type']) : CART_GENERAL_GOODS;
	
	    /* 检查购物车中是否有商品 */
	    $sql = "SELECT COUNT(*) FROM " . $ecs->table('cart') ." WHERE session_id = '" . SESS_ID . "' " .
	           "AND parent_id = 0 AND is_gift = 0 AND rec_type = '$flow_type'";
	    
		if ($db->getOne($sql) == 0)
	    {
			$msg = rpcLang('flow.php', 'no_goods_in_cart');
			jsonExit("{\"status\":\"$msg\"}");
	    }
	
	    /* 检查商品库存,如果使用库存,且下订单时减库存,则减少库存 */
	    if ($_CFG['use_storage'] == '1' && $_CFG['stock_dec_time'] == SDT_PLACE)
	    {
	        $cart_goods_stock = get_cart_goods();       
	        $_cart_goods_stock = array();        
	        foreach ($cart_goods_stock['goods_list'] as $value)
	        {
	            $_cart_goods_stock[$value['rec_id']] = $value['goods_number'];
	        }       
	        zy_flow_cart_stock($_cart_goods_stock);        
	        unset($cart_goods_stock, $_cart_goods_stock);
	    }
	
	    /*
	     * 检查用户是否已经登录
	     * 如果用户已经登录了则检查是否有默认的收货地址
	     * 如果没有登录则跳转到登录和注册页面
	     */
	    if (empty($_SESSION['direct_shopping']) && $_SESSION['user_id'] == 0)
	    {
	        /* 用户没有登录且没有选定匿名购物,转向到登录页面 */
	        $msg = rpcLang('user.php', 'nologin');
			jsonExit("{\"status\":\"$msg\"}");
	    }
	
	    $consignee = get_consignee($_SESSION['user_id']);
	
	    /* 检查收货人信息是否完整 */
	    if (!check_consignee_info($consignee, $flow_type))
	    {
	        $msg = rpcLang('flow.php', 'user_address_not_full');
			jsonExit("{\"status\":\"$msg\"}");
	    }
	
	
	    $_GET['how_oos']	  = isset($_GET['how_oos']) ? intval($_GET['how_oos']) : 0;
	    $_GET['card_message'] = isset($_GET['card_message']) ? htmlspecialchars($_GET['card_message']) : '';
	    $_GET['inv_type']     = !empty($_GET['inv_type']) ? htmlspecialchars($_GET['inv_type']) : '';
	    $_GET['inv_payee']    = isset($_GET['inv_payee']) ? htmlspecialchars($_GET['inv_payee']) : '';
	    $_GET['inv_content']  = isset($_GET['inv_content']) ? htmlspecialchars($_GET['inv_content']) : '';
	    $_GET['postscript']   = isset($_GET['postscript']) ? htmlspecialchars($_GET['postscript']) : '';
	
	    $referer = empty($_GET['referer']) ? 'Android':trim($_GET['referer']);
	    $order = array(
	        //'shipping_id'     => intval($_POST['shipping']),
	    	'shipping_id'     => intval($_GET['shipping']),//快递id
	        'pay_id'          => intval($_GET['payment']),//支付方式id
	        'pack_id'         => isset($_GET['pack']) ? intval($_GET['pack']) : 0,//包装
	        'card_id'         => isset($_GET['card']) ? intval($_GET['card']) : 0,//贺卡
	        'card_message'    => trim($_GET['card_message']),
	        'surplus'         => isset($_POST['surplus']) ? floatval($_POST['surplus']) : 0.00,
	        'integral'        => isset($_POST['integral']) ? intval($_POST['integral']) : 0,
	        'bonus_id'        => isset($_GET['bonus']) ? intval($_GET['bonus']) : 0,
	        'need_inv'        => empty($_POST['need_inv']) ? 0 : 1,
	        'postscript'      => trim($_POST['postscript']),
	        'how_oos'         => isset($_LANG['oos'][$_POST['how_oos']]) ? addslashes($_LANG['oos'][$_POST['how_oos']]) : '',
	        'need_insure'     => isset($_POST['need_insure']) ? intval($_POST['need_insure']) : 0,
	        'user_id'         => $_SESSION['user_id'],
	        'add_time'        => gmtime(),
	        'order_status'    => OS_UNCONFIRMED,
	        'shipping_status' => SS_UNSHIPPED,
	        'pay_status'      => PS_UNPAYED,
	        'agency_id'       => get_agency_by_regions(array($consignee['country'], $consignee['province'], $consignee['city'], $consignee['district']))
	        );
		if(EC_CHARSET == 'utf-8'){
			$order['inv_type'] = gbktoutf8($_GET['inv_type']);
			$order['inv_payee'] = gbktoutf8(trim($_GET['inv_payee']));
			$order['inv_content'] = gbktoutf8($_GET['inv_content']);
		}else{
			$order['inv_type'] = utf8togbk($_GET['inv_type']);
			$order['inv_payee'] = utf8togbk(trim($_GET['inv_payee']));
			$order['inv_content'] = utf8togbk($_GET['inv_content']);
		}
	
	    /* 扩展信息 */
	    if (isset($_SESSION['flow_type']) && intval($_SESSION['flow_type']) != CART_GENERAL_GOODS)
	    {
	        $order['extension_code'] = $_SESSION['extension_code'];
	        $order['extension_id'] = $_SESSION['extension_id'];
	    }
	    else
	    {
	        $order['extension_code'] = '';
	        $order['extension_id'] = 0;
	    }
	    $user_id = $_SESSION['user_id'];
		/*
	    #检查积分余额是否合法
	    $user_id = $_SESSION['user_id'];
	    if ($user_id > 0)
	    {
	        $user_info = user_info($user_id);
	
	        $order['surplus'] = min($order['surplus'], $user_info['user_money'] + $user_info['credit_line']);
	        if ($order['surplus'] < 0)
	        {
	            $order['surplus'] = 0;
	        }
	
	        // 查询用户有多少积分
	        $flow_points = flow_available_points();  // 该订单允许使用的积分
	        $user_points = $user_info['pay_points']; // 用户的积分总数
	
	        $order['integral'] = min($order['integral'], $user_points, $flow_points);
	        if ($order['integral'] < 0)
	        {
	            $order['integral'] = 0;
	        }
	    }
	    else
	    {
	        $order['surplus']  = 0;
	        $order['integral'] = 0;
	    }*/
	
	    #检查红包是否存在
	    if ($order['bonus_id'] > 0)
	    {
	        $bonus = bonus_info($order['bonus_id']);
	
	        if (empty($bonus) || $bonus['user_id'] != $user_id || $bonus['order_id'] > 0 || $bonus['min_goods_amount'] > cart_amount(true, $flow_type))
	        {
	            $order['bonus_id'] = 0;
	        }
	        
	    }
	    elseif (isset($_POST['bonus_sn']))
	    {
	        $bonus_sn = trim($_POST['bonus_sn']);
	        $bonus = bonus_info(0, $bonus_sn);
	        $now = gmtime();
	        if (empty($bonus) || $bonus['user_id'] > 0 || $bonus['order_id'] > 0 || $bonus['min_goods_amount'] > cart_amount(true, $flow_type) || $now > $bonus['use_end_date'])
	        {
	        }
	        else
	        {
	            if ($user_id > 0)
	            {
	                $sql = "UPDATE " . $ecs->table('user_bonus') . " SET user_id = '$user_id' WHERE bonus_id = '$bonus[bonus_id]' LIMIT 1";
	                $db->query($sql);
	            }
	            $order['bonus_id'] = $bonus['bonus_id'];
	            $order['bonus_sn'] = $bonus_sn;
	        }
	    }
		
	
	    /* 订单中的商品 */
	    $cart_goods = cart_goods($flow_type);
	
	    if (empty($cart_goods))
	    {
	        $msg = rpcLang('flow.php', 'no_goods_in_cart');
			jsonExit("{\"status\":\"$msg\"}");
	    }
	
	    /* 检查商品总额是否达到最低限购金额 */
	    if ($flow_type == CART_GENERAL_GOODS && cart_amount(true, CART_GENERAL_GOODS) < $_CFG['min_goods_amount'])
	    {
			$msg = rpcLang('flow.php', 'goods_amount_not_enough');
			jsonExit("{\"status\":\"$msg\"}");
	    }
	
	    /* 收货人信息 */
	    foreach ($consignee as $key => $value)
	    {
	        $order[$key] = addslashes($value);
	    }
	
	    /* 订单中的总额 */
	    $total = order_fee($order, $cart_goods, $consignee);
	
	    $order['bonus']        = $total['bonus'];
	    $order['goods_amount'] = $total['goods_price'];
	    $order['discount']     = $total['discount'];
	    $order['surplus']      = $total['surplus'];
	    $order['tax']          = $total['tax'];
	    #购物车中的商品能享受红包支付的总额
	    $discount_amout = compute_discount_amount();
		#红包和积分最多能支付的金额为商品总额
	    $temp_amout = $order['goods_amount'] - $discount_amout;
		if ($temp_amout <= 0)
	    {
	        $order['bonus_id'] = 0;
	    }
	
	    /* 配送方式 */
	    if ($order['shipping_id'] > 0)
	    {
	        $shipping = shipping_info($order['shipping_id']);
	        $order['shipping_name'] = addslashes($shipping['shipping_name']);
	    }
	    $order['shipping_fee'] = $total['shipping_fee'];
	    $order['insure_fee']   = $total['shipping_insure'];
	
	    /* 支付方式 */
	    if ($order['pay_id'] > 0)
	    {
	        $payment = payment_info($order['pay_id']);
	        $order['pay_name'] = addslashes($payment['pay_name']);
	    }
	    $order['pay_fee'] = $total['pay_fee'];
	    $order['cod_fee'] = $total['cod_fee'];
	
	    /* 商品包装 */
	    if ($order['pack_id'] > 0)
	    {
	        $pack               = pack_info($order['pack_id']);
	        $order['pack_name'] = addslashes($pack['pack_name']);
	    }
	    $order['pack_fee'] = $total['pack_fee'];
	
	
	    /* 祝福贺卡 */
	    if ($order['card_id'] > 0)
	    {
	        $card               = card_info($order['card_id']);
	        $order['card_name'] = addslashes($card['card_name']);
	    }
	    $order['card_fee']      = $total['card_fee'];
	
	    $order['order_amount']  = number_format($total['amount'], 2, '.', '');
	
	    /* 如果全部使用余额支付,检查余额是否足够 */
	    if ($payment['pay_code'] == 'balance' && $order['order_amount'] > 0)
	    {
	        if($order['surplus'] >0) //余额支付里如果输入了一个金额
	        {
	            $order['order_amount'] = $order['order_amount'] + $order['surplus'];
	            $order['surplus'] = 0;
	        }
	        if ($order['order_amount'] > ($user_info['user_money'] + $user_info['credit_line']))
	        {
	            show_message($_LANG['balance_not_enough']);
	        }
	        else
	        {
	            $order['surplus'] = $order['order_amount'];
	            $order['order_amount'] = 0;
	        }
	    }
	
	    /* 如果订单金额为0(使用余额或积分或红包支付),修改订单状态为已确认、已付款 */
	    if ($order['order_amount'] <= 0)
	    {
	        $order['order_status'] = OS_CONFIRMED;
	        $order['confirm_time'] = gmtime();
	        $order['pay_status']   = PS_PAYED;
	        $order['pay_time']     = gmtime();
	        $order['order_amount'] = 0;
	    }
	
	    $order['integral_money']   = $total['integral_money'];
	    $order['integral']         = $total['integral'];
	
	    if ($order['extension_code'] == 'exchange_goods')
	    {
	        $order['integral_money']   = 0;
	        $order['integral']         = $total['exchange_integral'];
	    }
	
	    $order['from_ad']          = !empty($_SESSION['from_ad']) ? $_SESSION['from_ad'] : '0';
	    $order['referer']          = !empty($_SESSION['referer']) ? addslashes($_SESSION['referer']) : '';
	
	    /* 记录扩展信息 */
	    if ($flow_type != CART_GENERAL_GOODS)
	    {
	        $order['extension_code'] = $_SESSION['extension_code'];
	        $order['extension_id'] = $_SESSION['extension_id'];
	    }
	
	    $affiliate = unserialize($_CFG['affiliate']);
	    if(isset($affiliate['on']) && $affiliate['on'] == 1 && $affiliate['config']['separate_by'] == 1)
	    {
	        //推荐订单分成
	        $parent_id = get_affiliate();
	        if($user_id == $parent_id)
	        {
	            $parent_id = 0;
	        }
	    }
	    elseif(isset($affiliate['on']) && $affiliate['on'] == 1 && $affiliate['config']['separate_by'] == 0)
	    {
	        //推荐注册分成
	        $parent_id = 0;
	    }
	    else
	    {
	        //分成功能关闭
	        $parent_id = 0;
	    }
	    $order['parent_id'] = $parent_id;
	
	    /* 插入订单表 */
	    $error_no = 0;
	    do
	    {
	        $order['order_sn'] = get_order_sn(); //获取新订单号
			
	        $GLOBALS['db']->autoExecute($GLOBALS['ecs']->table('order_info'), $order, 'INSERT');
	
	        $error_no = $GLOBALS['db']->errno();
	
	        if ($error_no > 0 && $error_no != 1062)
	        {
	            die($GLOBALS['db']->errorMsg());
	        }
	    }
	    while ($error_no == 1062); //如果是订单号重复则重新提交数据
	
	    $new_order_id = $db->insert_id();
	    $order['order_id'] = $new_order_id;
	
	    /* 插入订单商品 */
	    $sql = "INSERT INTO " . $ecs->table('order_goods') . "( " .
	                "order_id, goods_id, goods_name, goods_sn, goods_number, market_price, ".
	                "goods_price, goods_attr, is_real, extension_code, parent_id, is_gift, goods_attr_id) ".
	            " SELECT '$new_order_id', goods_id, goods_name, goods_sn, goods_number, market_price, ".
	                "goods_price, goods_attr, is_real, extension_code, parent_id, is_gift, goods_attr_id".
	            " FROM " .$ecs->table('cart') .
	            " WHERE session_id = '".SESS_ID."' AND rec_type = '$flow_type'";
	    $db->query($sql);
	    /* 修改拍卖活动状态 */
	    if ($order['extension_code']=='auction')
	    {
	        $sql = "UPDATE ". $ecs->table('goods_activity') ." SET is_finished='2' WHERE act_id=".$order['extension_id'];
	        $db->query($sql);
	    }
	
	    /* 处理余额、积分、红包 */
	    if ($order['user_id'] > 0 && $order['surplus'] > 0)
	    {
	        log_account_change($order['user_id'], $order['surplus'] * (-1), 0, 0, 0, sprintf($_LANG['pay_order'], $order['order_sn']));
	    }
	    if ($order['user_id'] > 0 && $order['integral'] > 0)
	    {
	        log_account_change($order['user_id'], 0, 0, 0, $order['integral'] * (-1), sprintf($_LANG['pay_order'], $order['order_sn']));
	    }
	
	    if ($order['bonus_id'] > 0 && $temp_amout > 0)
	    {
	        use_bonus($order['bonus_id'], $new_order_id);
	    }
	
	    /* 如果使用库存,且下订单时减库存,则减少库存 */
	    if ($_CFG['use_storage'] == '1' && $_CFG['stock_dec_time'] == SDT_PLACE)
	    {
	        //change_order_goods_storage($order['order_id'], true, SDT_PLACE);
	    }
	error_log('1',3,'flow.log');
	    /* 给商家发邮件 */
	    /* 增加是否给客服发送邮件选项 */
	    if ($_CFG['send_service_email'] && $_CFG['service_email'] != '')
	    {
	    	error_log('2',3,'flow.log');
	        $tpl = get_mail_template('remind_of_new_order');
			/*
			$smarty->assign('order', $order);
	        $smarty->assign('goods_list', $cart_goods);
	        $smarty->assign('shop_name', $_CFG['shop_name']);
	        $smarty->assign('send_date', date($_CFG['time_format']));
	        $content = $smarty->fetch('str:' . $tpl['template_content']);
	        */
			send_mail($_CFG['shop_name'], $_CFG['service_email'], $tpl['template_subject'], $content, $tpl['is_html']);
	    }
	error_log('2',3,'flow.log');
	    /* 如果需要,发短信 */
	    if ($_CFG['sms_order_placed'] == '1' && $_CFG['sms_shop_mobile'] != '')
	    {
	        include_once(RPC_ROOT.'includes/cls_sms.php');
	        $sms = new sms();
	        $msg = $order['pay_status'] == PS_UNPAYED ?
	            $_LANG['order_placed_sms'] : $_LANG['order_placed_sms'] . '[' . $_LANG['sms_paid'] . ']';
	        $sms->send($_CFG['sms_shop_mobile'], sprintf($msg, $order['consignee'], $order['tel']), 0);
	    }
	error_log('3',3,'flow.log');
	    /* 如果订单金额为0 处理虚拟卡 */
	    if ($order['order_amount'] <= 0)
	    {
	        $sql = " SELECT goods_id, goods_name, goods_number AS num FROM ".$GLOBALS['ecs']->table('cart') .
	               " 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'];
	
	        $pay_online = $pay_obj->get_code($order, unserialize_config($payment['pay_config']));
	
	        $order['pay_desc'] = $payment['pay_desc'];
	
	        $smarty->assign('pay_online', $pay_online);
	    }
		*/
	
	    if(!empty($order['shipping_name']))
	    {
	        $order['shipping_name']=trim(stripcslashes($order['shipping_name']));
	    }
	error_log('9',3,'flow.log');
	    /*
		#订单信息
	    $smarty->assign('order',      $order);
	    $smarty->assign('total',      $total);
	    $smarty->assign('goods_list', $cart_goods);
	    $smarty->assign('order_submit_back', sprintf($_LANG['order_submit_back'], $_LANG['back_home'], $_LANG['goto_user_center'])); // 返回提示
		*/
	    //user_uc_call('add_feed', array($order['order_id'], BUY_GOODS)); //推送feed到uc
	    unset($_SESSION['flow_consignee']); // 清除session中保存的收货人信息
	    unset($_SESSION['flow_order']);
	    unset($_SESSION['direct_shopping']);
	
	
		$order_done = array('order'=>$order,'total'=>$total,'cart_goods'=>$cart_goods);
		//var_dump($order_done);exit;
	error_log('10',3,'flow.log');	
		$order_id = $order['order_id'];
		$price = $order['order_amount'];
		$order = array ('order_id'=>$order_id,'order_number'=>$order['order_sn'],'price'=>$price) ;
		error_log('11',3,'flow.log');
		//print_r($order);die;
		jsonExit($order);
		
	}
Ejemplo n.º 10
0
 admin_priv('back_view');
 $status_refund = '1';
 $back_id = intval(trim($_REQUEST['back_id']));
 // 退换货订单id
 $action_note = isset($_REQUEST['action_note']) ? trim($_REQUEST['action_note']) : '';
 $order = back_order_info($back_id);
 $sql = "update " . $ecs->table('back_goods') . " set status_refund='{$status_refund}'  where back_id='{$back_id}' and (back_type='0' or back_type='4') ";
 $db->query($sql);
 $refund_money_2 = $_REQUEST['refund_money_2'] + $_REQUEST['refund_shipping_fee'];
 $refund_desc = $_REQUEST['refund_desc'] . ($_REQUEST['refund_shipping'] ? '\\n(已退运费:' . $_REQUEST['refund_shipping_fee'] . ')' : '');
 $sql2 = "update " . $ecs->table('back_order') . " set  status_refund='{$status_refund}',  refund_money_2='{$refund_money_2}', refund_type='{$_REQUEST['refund_type']}', refund_desc='{$refund_desc}' where back_id='{$back_id}' ";
 $db->query($sql2);
 /* 退回用户余额 */
 if ($_REQUEST['refund_type'] == '1') {
     $desc_back = "订单" . $order['order_id'] . '退款';
     log_account_change($order['user_id'], $refund_money_2, 0, 0, 0, $desc_back);
     //是否开启余额变动给客户发短信-退款
     if ($_CFG['sms_user_money_change'] == 1) {
         $sql = "SELECT user_money,mobile_phone FROM " . $GLOBALS['ecs']->table('users') . " WHERE user_id = '" . $order['user_id'] . "'";
         $users = $GLOBALS['db']->getRow($sql);
         $content = sprintf($_CFG['sms_return_goods_tpl'], $refund_money_2, $users['user_money'], $_CFG['sms_sign']);
         if ($users['mobile_phone']) {
             include_once '../send.php';
             sendSMS($users['mobile_phone'], $content);
         }
     }
 }
 /* 记录log */
 back_action($back_id, $order['status_back'], $status_refund, $action_note);
 $links[] = array('text' => '返回退款/退货及维修详情', 'href' => 'back.php?act=back_info&back_id=' . $back_id);
 sys_msg('恭喜,成功操作!', 1, $links);
Ejemplo n.º 11
0
 function sendIntegral($wxid, $num = 0, $key = "")
 {
     $uid = $this->isBindUser($wxid);
     if ($uid) {
         if ($key) {
             $sql = "SELECT * FROM " . $GLOBALS['ecs']->table('weixin_keywords') . " where `key`='{$key}'";
             $rs = $GLOBALS['db']->getRow($sql);
             if ($rs && $rs['jf_type'] > 0 && $rs['jf_num'] > 0) {
                 $num = $rs['jf_num'];
                 if ($rs['jf_type'] == 1) {
                     $maxNum = $GLOBALS['db']->getOne("SELECT sum(num) FROM " . $GLOBALS['ecs']->table('weixin_jflog') . " where fake_id='{$wxid}' and `key_id`='{$rs['id']}'");
                     if ($maxNum > 0) {
                         return false;
                     }
                 }
                 if ($rs['jf_type'] == 2) {
                     $ymd = date('Y-m-d');
                     $maxNum = $GLOBALS['db']->getOne("SELECT sum(num) FROM " . $GLOBALS['ecs']->table('weixin_jflog') . " where fake_id='{$wxid}' and `key_id`='{${$rs['id']}}' and createymd='{$ymd}'");
                     if ($maxNum + $rs['jf_num'] > $rs['jf_maxnum']) {
                         return false;
                     }
                 }
             }
         }
         if ($num > 0) {
             log_account_change($uid, 0, 0, 0, $num, "微信活动赠送积分");
             $createtime = time();
             $createymd = date('Y-m-d');
             $GLOBALS['db']->query("insert into " . $GLOBALS['ecs']->table('weixin_jflog') . " (`fake_id`,`jf_type`,`key_id`,`createtime`,`createymd`,`num`) value (\n\t\t\t\t\t'{$wxid}','{$rs['jf_type']}','{$rs['id']}','{$createtime}','{$createymd}','{$num}')");
         }
         return true;
     }
     return false;
 }
Ejemplo n.º 12
0
        $db->query($sql);
    }
    $links[] = array('text' => $_LANG['affiliate_ck'], 'href' => 'affiliate_ck.php?act=list');
    sys_msg($_LANG['edit_ok'], 0, $links);
} elseif ($_REQUEST['act'] == 'rollback') {
    $logid = (int) $_REQUEST['logid'];
    $stat = $db->getRow("SELECT * FROM " . $GLOBALS['ecs']->table('affiliate_log') . " WHERE log_id = '{$logid}'");
    if (!empty($stat)) {
        if ($stat['separate_type'] == 1) {
            //推荐订单分成
            $flag = -2;
        } else {
            //推荐注册分成
            $flag = -1;
        }
        log_account_change($stat['user_id'], -$stat['money'], 0, -$stat['point'], 0, $_LANG['loginfo']['cancel']);
        $sql = "UPDATE " . $GLOBALS['ecs']->table('affiliate_log') . " SET separate_type = '{$flag}'" . " WHERE log_id = '{$logid}'";
        $db->query($sql);
    }
    $links[] = array('text' => $_LANG['affiliate_ck'], 'href' => 'affiliate_ck.php?act=list');
    sys_msg($_LANG['edit_ok'], 0, $links);
} elseif ($_REQUEST['act'] == 'separate') {
    include_once ROOT_PATH . 'includes/lib_order.php';
    require_once 'SqlHelper.php';
    $sqlhelper = new SqlHelper();
    $affiliate = unserialize($GLOBALS['_CFG']['affiliate']);
    empty($affiliate) && ($affiliate = array());
    $separate_by = $affiliate['config']['separate_by'];
    $oid = (int) $_REQUEST['oid'];
    $order_id = $oid;
    //根据订单Id求买家id
Ejemplo n.º 13
0
function action_vc_login_act()
{
	$user = $GLOBALS['user'];
	$_CFG = $GLOBALS['_CFG'];
	$_LANG = $GLOBALS['_LANG'];
	$smarty = $GLOBALS['smarty'];
	$db = $GLOBALS['db'];
	$ecs = $GLOBALS['ecs'];
	$user_id = $GLOBALS['user_id'];


	include_once (ROOT_PATH . 'includes/lib_clips.php');
	$nowtime = gmtime();
	$vc_sn = isset($_POST['vcard']) ? trim($_POST['vcard']) : '';
	$vc_pwd = isset($_POST['pwd']) ? trim($_POST['pwd']) : '';
	if(empty($vc_sn) || empty($vc_pwd))
	{
		show_message('卡号或密码都不能为空', '返回重新登录', 'user.php?act=vc_login');
	}
	$sql = "select vc.*, vt.type_money, vt.use_start_date, vt.use_end_date from " . $ecs->table('valuecard') . " AS vc " . " left join " . $ecs->table('valuecard_type') . " AS vt " . "on vc.vc_type_id = vt.type_id where vc.vc_sn= '$vc_sn' ";
	$vcrow = $db->getRow($sql);
	if(! $vcrow)
	{
		show_message('该储值卡号不存在', '请查证后重新登录', 'user.php?act=vc_login');
	}
	if($vc_pwd != $vcrow['vc_pwd'])
	{
		show_message('密码错误', '请查证后重新登录', 'user.php?act=vc_login');
	}
	if($nowtime < $vcrow['use_start_date'])
	{
		show_message('对不起,该储值卡还未到开始使用日期', '请过几天再登录试试', 'user.php?act=vc_login');
	}
	if($nowtime > $vcrow['use_end_date'])
	{
		show_message('对不起,该储值卡已过期', '请换个卡号重新登录', 'user.php?act=vc_login');
	}
	if($vcrow['user_id'])
	{
		show_message('对不起,该储值卡已使用', '请换个卡号重新登录', 'user.php?act=vc_login');
	}
	
	$sql = 'INSERT INTO ' . $GLOBALS['ecs']->table('user_account') . ' (user_id, admin_user, amount, add_time, paid_time, admin_note, user_note, process_type, payment, is_paid)' . " VALUES ('$user_id', '', '$vcrow[type_money]', '" . gmtime() . "', '" . gmtime() . "', '', '储值卡充值', '0', '储值卡号:$vc_sn', 1)";
	$GLOBALS['db']->query($sql);
	log_account_change($user_id, $vcrow['type_money'], 0, 0, 0, '储值卡充值,卡号:' . $vc_sn, ACT_OTHER);
	
	$sql = "update " . $ecs->table('valuecard') . " set user_id='$user_id', used_time='$nowtime' where vc_id='$vcrow[vc_id]' ";
	$db->query($sql);
	
	show_message('恭喜,已成功充值!', '返回上一页', 'user.php?act=vc_login');
	
	$smarty->display('user_transaction.dwt');
}
Ejemplo n.º 14
0
/**
 * 取消一个用户订单
 *
 * @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;
    }
}
Ejemplo n.º 15
0
/**
 * 取消一个用户订单
 *
 * @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());
    }
}
Ejemplo n.º 16
0
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);
}
Ejemplo n.º 17
0
/**
 * 用户注册,登录函数
 *
 * @access  public
 * @param   string       $username          注册用户名
 * @param   string       $password          用户密码
 * @param   string       $email             注册email
 * @param   array        $other             注册的其他信息
 *
 * @return  bool         $bool
 */
function register($username, $password, $other = array())
{
    /* 检查注册是否关闭 */
    if (!empty($GLOBALS['_CFG']['shop_reg_closed'])) {
        $GLOBALS['err']->add($GLOBALS['_LANG']['shop_register_closed']);
    }
    /* 检查username */
    if (empty($username)) {
        $GLOBALS['err']->add($GLOBALS['_LANG']['username_empty']);
    } else {
        if (preg_match('/\'\\/^\\s*$|^c:\\\\con\\\\con$|[%,\\*\\"\\s\\t\\<\\>\\&\'\\\\]/', $username)) {
            $GLOBALS['err']->add(sprintf($GLOBALS['_LANG']['username_invalid'], htmlspecialchars($username)));
        }
    }
    /* 检查是否和管理员重名 */
    if (admin_registered($username)) {
        $GLOBALS['err']->add(sprintf($GLOBALS['_LANG']['username_exist'], $username));
        return false;
    }
    if (!$GLOBALS['user']->add_user($username, $password, $email)) {
        if ($GLOBALS['user']->error == ERR_INVALID_USERNAME) {
            $GLOBALS['err']->add(sprintf($GLOBALS['_LANG']['username_invalid'], $username));
        } elseif ($GLOBALS['user']->error == ERR_USERNAME_NOT_ALLOW) {
            $GLOBALS['err']->add(sprintf($GLOBALS['_LANG']['username_not_allow'], $username));
        } elseif ($GLOBALS['user']->error == ERR_USERNAME_EXISTS) {
            $GLOBALS['err']->add(sprintf($GLOBALS['_LANG']['username_exist'], $username));
        } else {
            $GLOBALS['err']->add('UNKNOWN ERROR!');
        }
        //注册失败
        return false;
    } else {
        //注册成功
        /* 设置成登录状态 */
        $GLOBALS['user']->set_session($username);
        $GLOBALS['user']->set_cookie($username);
        /* 注册送积分 */
        if (!empty($GLOBALS['_CFG']['register_points'])) {
            log_account_change($_SESSION['user_id'], 0, 0, $GLOBALS['_CFG']['register_points'], $GLOBALS['_CFG']['register_points'], $GLOBALS['_LANG']['register_points']);
        }
        /*推荐处理*/
        $affiliate = unserialize($GLOBALS['_CFG']['affiliate']);
        if (isset($affiliate['on']) && $affiliate['on'] == 1) {
            // 推荐开关开启
            $up_uid = get_affiliate();
            empty($affiliate) && ($affiliate = array());
            $affiliate['config']['level_register_all'] = intval($affiliate['config']['level_register_all']);
            $affiliate['config']['level_register_up'] = intval($affiliate['config']['level_register_up']);
            if ($up_uid) {
                if (!empty($affiliate['config']['level_register_all'])) {
                    if (!empty($affiliate['config']['level_register_up'])) {
                        $rank_points = $GLOBALS['db']->getOne("SELECT rank_points FROM " . $GLOBALS['ecs']->table('users') . " WHERE user_id = '{$up_uid}'");
                        if ($rank_points + $affiliate['config']['level_register_all'] <= $affiliate['config']['level_register_up']) {
                            log_account_change($up_uid, 0, 0, $affiliate['config']['level_register_all'], 0, sprintf($GLOBALS['_LANG']['register_affiliate'], $_SESSION['user_id'], $username));
                        }
                    } else {
                        log_account_change($up_uid, 0, 0, $affiliate['config']['level_register_all'], 0, $GLOBALS['_LANG']['register_affiliate']);
                    }
                }
                //设置推荐人
                $sql = 'UPDATE ' . $GLOBALS['ecs']->table('users') . ' SET parent_id = ' . $up_uid . ' WHERE user_id = ' . $_SESSION['user_id'];
                $GLOBALS['db']->query($sql);
            }
        }
        //定义other合法的变量数组
        $other_key_array = array('msn', 'qq', 'office_phone', 'home_phone', 'mobile_phone', 'sina_weibo_id');
        $update_data['reg_time'] = local_strtotime(local_date('Y-m-d H:i:s'));
        if ($other) {
            foreach ($other as $key => $val) {
                //删除非法key值
                if (!in_array($key, $other_key_array)) {
                    unset($other[$key]);
                } else {
                    $other[$key] = htmlspecialchars(trim($val));
                    //防止用户输入javascript代码
                }
            }
            $update_data = array_merge($update_data, $other);
        }
        $GLOBALS['db']->autoExecute($GLOBALS['ecs']->table('users'), $update_data, 'UPDATE', 'user_id = ' . $_SESSION['user_id']);
        update_user_info();
        // 更新用户信息
        recalculate_price();
        // 重新计算购物车中的商品价格
        return true;
    }
}
Ejemplo n.º 18
0
                        $msg = "分享成功!积分+" . $qd_jf;
                    }
                } else {
                    $msg = "此功能微开启";
                }
            } else {
                $msg = "今天的分享次数已经用完";
            }
        } elseif ($type == 2) {
            if (record_point("share_fpoint", $fromUsername)) {
                $jf_state = $db->getOne("SELECT `autoload` FROM `wxch_point` WHERE `point_name` = 'share_fpoint'");
                if ($jf_state == 'yes') {
                    $info = "分享朋友圈返积分" . $qd_jf;
                    $qd_jf = $db->getOne("SELECT `point_value` FROM `wxch_point` WHERE `point_name` = 'share_fpoint'");
                    if ($qd_jf > 0) {
                        log_account_change($user_id, 0, 0, 0, $qd_jf, $info);
                        $msg = "分享成功!积分+" . $qd_jf;
                    }
                } else {
                    $msg = "此功能微开启";
                }
            } else {
                $msg = "今天的分享次数已经用完";
            }
        } else {
            $msg = "非法请求";
        }
    }
}
assign_template();
$position = assign_ur_here();
Ejemplo n.º 19
0
     }
     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()));
                 /* 如果订单用户不为空,计算积分,并发给用户;发红包 */
                 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']));
                     /* 发放红包 */
                     send_order_bonus($order['order_id']);
                 }
             }
         }
     }
 }
 /* 清空购物车 */
 clear_cart($flow_type);
 /* 清除缓存,否则买了商品,但是前台页面读取缓存,商品数量不减少 */
 clear_all_files();
 /* 插入支付日志 */
 $order['log_id'] = insert_pay_log($new_order_id, $order['order_amount'], PAY_ORDER);
 /* 取得支付信息,生成支付代码 */
 if ($order['order_amount'] > 0) {
Ejemplo n.º 20
0
function bindusercard($co = '')
{
    global $_SESSION;
    $card_no = empty($co) ? $_SESSION['ucardno'] : $co;
    $sql = "select * from " . $GLOBALS['ecs']->table('user_card') . " where card_no='" . $card_no . "' ";
    $card_info = $GLOBALS['db']->getRow($sql);
    $GLOBALS['db']->query("update " . $GLOBALS['ecs']->table('user_card') . " set user_id='{$_SESSION['user_id']}', bind_time ='" . gmtime() . "', card_status=1 where card_no='{$card_no}' limit 1 ");
    $arr['user_money'] = floatval($card_info['user_money']);
    $arr['pay_points'] = $card_info['pay_points'];
    $arr['rank_points'] = $card_info['rank_points'];
    if ($card_info['card_level']) {
        $card_rank = $GLOBALS['db']->getOne(" select rank_id from " . $GLOBALS['ecs']->table('user_rank') . " where rank_name='{$card_info['card_level']}' ");
        if ($card_rank) {
            $arr['user_rank'] = $card_rank;
        }
        $sql = 'UPDATE ' . $GLOBALS['ecs']->table('users') . " SET `user_rank`='{$card_rank}'  WHERE `user_id`='" . $_SESSION['user_id'] . "'";
        $GLOBALS['db']->query($sql);
    }
    log_account_change($_SESSION['user_id'], $arr['user_money'], 0, $arr['rank_points'], $arr['pay_points'], '绑定会卡' . $card_no . '充值等级积分:' . $arr['rank_points'] . ',消费积分' . $arr['pay_points']);
    $sql = 'UPDATE ' . $GLOBALS['ecs']->table('user_card') . " SET `user_money`='0', `pay_points`='0', `rank_points`='0'  WHERE `card_no`='" . $card_no . "'";
    $GLOBALS['db']->query($sql);
    $from_date = gmtime();
    $to_date = local_strtotime("" . HE_TONG_DAYS . " day");
    $sql = 'UPDATE ' . $GLOBALS['ecs']->table('users') . " SET `from_date`='" . $from_date . "',to_date='" . $to_date . "'  WHERE `user_id`='" . $_SESSION['user_id'] . "'";
    $GLOBALS['db']->query($sql);
}
Ejemplo n.º 21
0
    /* 检查用户是否已经出同一价格 */
    $sql = 'SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('snatch_log') . " WHERE snatch_id = '{$id}' AND user_id = '{$_SESSION['user_id']}' AND bid_price = '{$price}'";
    if ($GLOBALS['db']->getOne($sql) > 0) {
        $result['error'] = 1;
        $result['content'] = sprintf($GLOBALS['_LANG']['also_bid'], price_format($price, false));
        die($json->encode($result));
    }
    /* 检查用户积分是否足够 */
    $sql = 'SELECT pay_points FROM ' . $ecs->table('users') . " WHERE user_id = '" . $_SESSION['user_id'] . "'";
    $pay_points = $db->getOne($sql);
    if ($row['cost_points'] > $pay_points) {
        $result['error'] = 1;
        $result['content'] = $_LANG['lack_pay_points'];
        die($json->encode($result));
    }
    log_account_change($_SESSION['user_id'], 0, 0, 0, 0 - $row['cost_points'], sprintf($_LANG['snatch_log'], $row['snatch_name']));
    //扣除用户积分
    $sql = 'INSERT INTO ' . $ecs->table('snatch_log') . '(snatch_id, user_id, bid_price, bid_time) VALUES' . "('{$id}', '" . $_SESSION['user_id'] . "', '" . $price . "', " . gmtime() . ")";
    $db->query($sql);
    $smarty->assign('myprice', get_myprice($id));
    $smarty->assign('id', $id);
    $result['content'] = $smarty->fetch('library/snatch.lbi');
    die($json->encode($result));
}
/*------------------------------------------------------ */
//-- 购买商品
/*------------------------------------------------------ */
if ($_REQUEST['act'] == 'buy') {
    if (empty($id)) {
        ecs_header("Location: ./\n");
        exit;
Ejemplo n.º 22
0
<?php

define('IN_ECS', true);
require dirname(__FILE__) . '/includes/init.php';
// 获得所有有效会员清单
$sql_memeber = "select u.user_id, u.email, u.user_name,u.user_money,u.rank_points, u.msn, u.to_date from " . $ecs->table("users") . " u  where u.member_novalid ='0' and (u.msn is not null or u.msn <> '') ";
$member_list = $db->getAll($sql_memeber);
if ($member_list) {
    foreach ($member_list as $user) {
        if (!empty($user['to_date']) and $user['to_date'] < gmtime()) {
            //判断合同期限
            //if ($GLOBALS['_CFG']['send_service_email'] == '1' && $GLOBALS['_CFG']['kf'] != '')
            if ($GLOBALS['_CFG']['send_service_email'] == '1') {
                $tpl = get_mail_template('member_novalid');
                $smarty->assign('user', $user);
                $smarty->assign('shop_name', $GLOBALS['_CFG']['shop_name']);
                $smarty->assign('send_date', date($GLOBALS['_CFG']['time_format']));
                $content = $smarty->fetch('str:' . $tpl['template_content']);
                send_mail($_CFG['shop_name'], "*****@*****.**", $tpl['template_subject'], $content, $tpl['is_html']);
            }
            $db->query("update " . $ecs->table("users") . " set member_novalid='1' and rank_points='0' where user_id=" . $user['user_id']);
            log_account_change($user['user_id'], 0, 0, -$user['rank_points'], 0, '会员过期自动清理', ACT_OTHER);
        }
    }
    exit;
}
?>
 
Ejemplo n.º 23
0
     if ($error_no > 0 && $error_no != 1062) {
         die($GLOBALS['db']->errorMsg());
     }
 } while ($error_no == 1062);
 //如果是订单号重复则重新提交数据
 $new_order_id = $db->insert_id();
 $order['order_id'] = $new_order_id;
 /* 插入订单商品 */
 $sql = "INSERT INTO " . $ecs->table('order_goods') . "( " . "order_id, goods_id, goods_name, goods_sn, goods_number, market_price, " . "goods_price, goods_attr, is_real, extension_code, parent_id, is_gift, goods_attr_id) " . " SELECT '{$new_order_id}', goods_id, goods_name, goods_sn, goods_number, market_price, " . "goods_price, goods_attr, is_real, extension_code, parent_id, is_gift, goods_attr_id" . " FROM " . $ecs->table('cart') . " WHERE session_id = '" . SESS_ID . "' AND rec_type = '{$flow_type}'";
 $db->query($sql);
 /* 处理余额、积分、红包 */
 if ($order['user_id'] > 0 && $order['surplus'] > 0) {
     log_account_change($order['user_id'], $order['surplus'] * -1, 0, 0, 0, sprintf('支付订单 %s', $order['order_sn']));
 }
 if ($order['user_id'] > 0 && $order['integral'] > 0) {
     log_account_change($order['user_id'], 0, 0, 0, $order['integral'] * -1, sprintf('支付订单 %s', $order['order_sn']));
 }
 /* 如果使用库存,且下订单时减库存,则减少库存 */
 if ($_CFG['use_storage'] == '1' && $_CFG['stock_dec_time'] == SDT_PLACE) {
     change_order_goods_storage($order['order_id'], true, SDT_PLACE);
 }
 /* 清空购物车 */
 clear_cart($flow_type);
 /* 清除缓存,否则买了商品,但是前台页面读取缓存,商品数量不减少 */
 clear_all_files();
 if (!empty($order['shipping_name'])) {
     $order['shipping_name'] = trim(stripcslashes($order['shipping_name']));
 }
 /* 取得支付信息,生成支付代码 */
 if ($order['order_amount'] > 0) {
     $payment = payment_info($order['pay_id']);
Ejemplo n.º 24
0
        empty($affiliate) && ($affiliate = array());
        $affiliate['config']['level_register_all'] = intval($affiliate['config']['level_register_all']);
        $affiliate['config']['level_register_up'] = intval($affiliate['config']['level_register_up']);
        //该用户是推荐来的
        if ($up_uid) {
            //标注此用户被推荐过了
            $info = array('state' => 1);
            $GLOBALS['db']->autoExecute($ecs->table('ip_log'), $info, 'UPDATE', "id = {$id}");
            if (!empty($affiliate['config']['level_register_all'])) {
                if (!empty($affiliate['config']['level_register_up'])) {
                    $rank_points = $GLOBALS['db']->getOne("SELECT rank_points FROM " . $GLOBALS['ecs']->table('users') . " WHERE user_id = '{$up_uid}'");
                    if ($rank_points + $affiliate['config']['level_register_all'] <= $affiliate['config']['level_register_up']) {
                        log_account_change($up_uid, 0, 0, $affiliate['config']['level_register_all'], $affiliate['config']['level_register_all'], sprintf($GLOBALS['_LANG']['register_affiliate'], $_SESSION['user_id'], $username));
                    }
                } else {
                    log_account_change($up_uid, 0, 0, $affiliate['config']['level_register_all'], 0, $GLOBALS['_LANG']['register_affiliate']);
                }
            }
            $sql = 'UPDATE ' . $GLOBALS['ecs']->table('users') . ' SET parent_id = ' . $up_uid . ' WHERE user_id = ' . $_SESSION['user_id'];
            $GLOBALS['db']->query($sql);
            require ROOT_PATH . 'wxch_share.php';
            //设置推荐人
        }
    }
}
if (!empty($_SESSION['user_id'])) {
    $user_id = $_SESSION['user_id'];
    $sql = "SELECT parent_id FROM " . $ecs->table('users') . "where user_id ='{$user_id}'";
    $parent_id = $GLOBALS['db']->getOne($sql);
    if (empty($parent_id)) {
        if (isset($_GET['u'])) {
Ejemplo n.º 25
0
    }
    if ($auction['status_no'] != FINISHED) {
        sys_msg($_LANG['invalid_status']);
    }
    if ($auction['deposit'] <= 0) {
        sys_msg($_LANG['no_deposit']);
    }
    /* 处理保证金 */
    $exc->edit("is_finished = 2", $id);
    // 修改状态
    if (isset($_POST['unfreeze'])) {
        /* 解冻 */
        log_account_change($auction['last_bid']['bid_user'], $auction['deposit'], -1 * $auction['deposit'], 0, 0, sprintf($_LANG['unfreeze_auction_deposit'], $auction['act_name']));
    } else {
        /* 扣除 */
        log_account_change($auction['last_bid']['bid_user'], 0, -1 * $auction['deposit'], 0, 0, sprintf($_LANG['deduct_auction_deposit'], $auction['act_name']));
    }
    /* 记日志 */
    admin_log($auction['act_name'], 'edit', 'auction');
    /* 清除缓存 */
    clear_cache_files();
    /* 提示信息 */
    sys_msg($_LANG['settle_deposit_ok']);
} elseif ($_REQUEST['act'] == 'search_goods') {
    check_authz_json('auction');
    include_once ROOT_PATH . 'includes/cls_json.php';
    $json = new JSON();
    $filter = $json->decode($_GET['JSON']);
    $arr['goods'] = get_goods_list($filter);
    if (!empty($arr['goods'][0]['goods_id'])) {
        $arr['products'] = get_good_products($arr['goods'][0]['goods_id']);
Ejemplo n.º 26
0
    }
    $user = user_info($user_id);
    if (empty($user)) {
        sys_msg($_LANG['user_not_exist']);
    }
    /* 提交值 */
    $change_desc = sub_str($_POST['change_desc'], 255, false);
    $user_money = floatval($_POST['add_sub_user_money']) * abs(floatval($_POST['user_money']));
    $frozen_money = floatval($_POST['add_sub_frozen_money']) * abs(floatval($_POST['frozen_money']));
    $rank_points = floatval($_POST['add_sub_rank_points']) * abs(floatval($_POST['rank_points']));
    $pay_points = floatval($_POST['add_sub_pay_points']) * abs(floatval($_POST['pay_points']));
    if ($user_money == 0 && $frozen_money == 0 && $rank_points == 0 && $pay_points == 0) {
        sys_msg($_LANG['no_account_change']);
    }
    /* 保存 */
    log_account_change($user_id, $user_money, $frozen_money, $rank_points, $pay_points, $change_desc, ACT_ADJUSTING);
    /* 提示信息 */
    $links = array(array('href' => 'account_log.php?act=list&user_id=' . $user_id, 'text' => $_LANG['account_list']));
    sys_msg($_LANG['log_account_change_ok'], 0, $links);
}
/**
 * 取得帐户明细
 * @param   int     $user_id    用户id
 * @param   string  $account_type   帐户类型:空表示所有帐户,user_money表示可用资金,
 *                  frozen_money表示冻结资金,rank_points表示等级积分,pay_points表示消费积分
 * @return  array
 */
function get_accountlist($user_id, $account_type = '')
{
    /* 检查参数 */
    $where = " WHERE user_id = '{$user_id}' ";
Ejemplo n.º 27
0
function action_vc_login_act()
{
    $user = $GLOBALS['user'];
    $_CFG = $GLOBALS['_CFG'];
    $_LANG = $GLOBALS['_LANG'];
    $smarty = $GLOBALS['smarty'];
    $db = $GLOBALS['db'];
    $ecs = $GLOBALS['ecs'];
    $user_id = $_SESSION['user_id'];
    include_once ROOT_PATH . 'includes/lib_clips.php';
    $nowtime = gmtime();
    $vc_sn = isset($_POST['vcard']) ? trim($_POST['vcard']) : '';
    $vc_pwd = isset($_POST['pwd']) ? trim($_POST['pwd']) : '';
    if (empty($vc_sn) || empty($vc_pwd)) {
        show_message('卡号或密码都不能为空', '返回重新登录', 'user.php?act=vc_login');
    }
    $sql = "select vc.*, vt.type_money, vt.use_start_date, vt.use_end_date from " . $ecs->table('valuecard') . " AS vc " . " left join " . $ecs->table('valuecard_type') . " AS vt " . "on vc.vc_type_id = vt.type_id where vc.vc_sn= '{$vc_sn}' ";
    $vcrow = $db->getRow($sql);
    if (!$vcrow) {
        show_message('该储值卡号不存在', '请查证后重新登录', 'user.php?act=vc_login');
    }
    if ($vc_pwd != $vcrow['vc_pwd']) {
        show_message('密码错误', '请查证后重新登录', 'user.php?act=vc_login');
    }
    if ($nowtime < $vcrow['use_start_date']) {
        show_message('对不起,该储值卡还未到开始使用日期', '请过几天再登录试试', 'user.php?act=vc_login');
    }
    if ($nowtime > $vcrow['use_end_date']) {
        show_message('对不起,该储值卡已过期', '请换个卡号重新登录', 'user.php?act=vc_login');
    }
    if ($vcrow['user_id']) {
        show_message('对不起,该储值卡已使用', '请换个卡号重新登录', 'user.php?act=vc_login');
    }
    $sql = 'INSERT INTO ' . $GLOBALS['ecs']->table('user_account') . ' (user_id, admin_user, amount, add_time, paid_time, admin_note, user_note, process_type, payment, is_paid)' . " VALUES ('{$user_id}', '', '{$vcrow['type_money']}', '" . gmtime() . "', '" . gmtime() . "', '', '储值卡充值', '0', '储值卡号:{$vc_sn}', 1)";
    $GLOBALS['db']->query($sql);
    log_account_change($user_id, $vcrow['type_money'], 0, 0, 0, '储值卡充值,卡号:' . $vc_sn, ACT_OTHER);
    $sql = "update " . $ecs->table('valuecard') . " set user_id='{$user_id}', used_time='{$nowtime}' where vc_id='{$vcrow['vc_id']}' ";
    $db->query($sql);
    // 是否开启余额变动给客户发短信-储值卡充值
    if ($_CFG['sms_user_money_change'] == 1) {
        $sql = "SELECT user_money,mobile_phone FROM " . $GLOBALS['ecs']->table('users') . " WHERE user_id = '{$user_id}'";
        $users = $GLOBALS['db']->getRow($sql);
        $content = sprintf($_CFG['sms_recharge_balance_add_tpl'], $vcrow['type_money'], $users['user_money'], $_CFG['sms_sign']);
        if ($users['mobile_phone']) {
            include_once 'send.php';
            sendSMS($users['mobile_phone'], $content);
        }
    }
    show_message('恭喜,已成功充值!', '返回上一页', 'user.php?act=vc_login');
    $smarty->display('user_transaction.dwt');
}
Ejemplo n.º 28
0
    /* 检查联系两次拍卖人是否相同 */
    if ($auction['last_bid']['bid_user'] == $user_id && $bid_price != $auction['end_price']) {
        show_message($_LANG['au_bid_repeat_user'], '', '', 'error');
    }
    /* 是否需要保证金 */
    if ($auction['deposit'] > 0) {
        /* 可用资金够吗 */
        if ($user['user_money'] < $auction['deposit']) {
            show_message($_LANG['au_user_money_short'], '', '', 'error');
        }
        /* 如果不是第一个出价,解冻上一个用户的保证金 */
        if ($auction['bid_user_count'] > 0) {
            log_account_change($auction['last_bid']['bid_user'], $auction['deposit'], -1 * $auction['deposit'], 0, 0, sprintf($_LANG['au_unfreeze_deposit'], $auction['act_name']));
        }
        /* 冻结当前用户的保证金 */
        log_account_change($user_id, -1 * $auction['deposit'], $auction['deposit'], 0, 0, sprintf($_LANG['au_freeze_deposit'], $auction['act_name']));
    }
    /* 插入出价记录 */
    $auction_log = array('act_id' => $id, 'bid_user' => $user_id, 'bid_price' => $bid_price, 'bid_time' => gmtime());
    $db->autoExecute($ecs->table('auction_log'), $auction_log, 'INSERT');
    /* 出价是否等于一口价 */
    if ($bid_price == $auction['end_price']) {
        /* 结束拍卖活动 */
        $sql = "UPDATE " . $ecs->table('goods_activity') . " SET is_finished = 1 WHERE act_id = '{$id}' LIMIT 1";
        $db->query($sql);
    }
    /* 跳转到活动详情页 */
    ecs_header("Location: auction.php?act=view&id={$id}\n");
    exit;
} elseif ($_REQUEST['act'] == 'buy') {
    /* 查询:取得参数:拍卖活动id */
Ejemplo n.º 29
0
/**
 * 取消一个用户订单
 *
 * @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());
    }
}
Ejemplo n.º 30
0
     } elseif ($users->error == ERR_USERNAME_EXISTS) {
         $msg = $_LANG['username_exists'];
     } elseif ($users->error == ERR_INVALID_EMAIL) {
         $msg = $_LANG['email_invalid'];
     } elseif ($users->error == ERR_EMAIL_NOT_ALLOW) {
         $msg = $_LANG['email_not_allow'];
     } elseif ($users->error == ERR_EMAIL_EXISTS) {
         $msg = $_LANG['email_exists'];
     } else {
         //die('Error:'.$users->error_msg());
     }
     sys_msg($msg, 1);
 }
 /* 注册送积分 */
 if (!empty($GLOBALS['_CFG']['register_points'])) {
     log_account_change($_SESSION['user_id'], 0, 0, $GLOBALS['_CFG']['register_points'], $GLOBALS['_CFG']['register_points'], $_LANG['register_points']);
 }
 /*把新注册用户的扩展信息插入数据库*/
 $sql = 'SELECT id FROM ' . $ecs->table('reg_fields') . ' WHERE type = 0 AND display = 1 ORDER BY dis_order, id';
 //读出所有扩展字段的id
 $fields_arr = $db->getAll($sql);
 $extend_field_str = '';
 //生成扩展字段的内容字符串
 $user_id_arr = $users->get_profile_by_name($username);
 foreach ($fields_arr as $val) {
     $extend_field_index = 'extend_field' . $val['id'];
     if (!empty($_POST[$extend_field_index])) {
         $temp_field_content = strlen($_POST[$extend_field_index]) > 100 ? mb_substr($_POST[$extend_field_index], 0, 99) : $_POST[$extend_field_index];
         $extend_field_str .= " ('" . $user_id_arr['user_id'] . "', '" . $val['id'] . "', '" . $temp_field_content . "'),";
     }
 }