function update_actions($glob) { $arr_action = give_action(); $cur_list_action = $glob['list_action']; $arr_action_add = array(); $arr_tmp = array(); for ($i = 0, $flag = 0; $cur_list_action[$i]; $i++) { for ($j = 0; $arr_action[$j]; $j++) { if (substr($cur_list_action[$i]['nom_action'], 0, 2) == "b_") { if ($cur_list_action[$i]['done'] == 0) { if ($cur_list_action[$i]['nom_action'] == $arr_action[$j]['nom']) { if ($flag == 0) { for ($k = 0; $arr_action[$j]['actions'][$k]; $k++) { array_push($arr_action_add, name_to_arr($arr_action[$j]['actions'][$k])); $arr_tmp = array(); } $cur_list_action = add_action_place($cur_list_action, $arr_action_add, $i); $arr_action_add = array(); $flag = 1; } } } } } } $cur_list_action = update_order($cur_list_action); $glob['list_action'] = $cur_list_action; return $glob; }
function add_note($idnote = 0) { global $dbh, $base_path, $idtype, $idobject, $comment, $ordre_cible; $iddemande = $idobject; $commentaire = trim($comment); if ($ordre_cible) { $ordre = $ordre_cible; } else { $req = "select max(ordre)+1 from rapport_demandes where num_demande='" . $iddemande . "'"; $res = mysql_query($req, $dbh); $ordre = mysql_result($res, 0, 0); } $req = "insert into rapport_demandes set \n\t\tcontenu='" . $commentaire . "',\n\t\tnum_demande='" . $iddemande . "',\n\t\tnum_note='" . $idnote . "',\n\t\tordre = '" . $ordre . "',\n\t\ttype='" . $idtype . "'\n\t\t"; mysql_query($req, $dbh); if ($ordre_cible) { update_order(mysql_insert_id()); } $req = "select rd.id_item, rd.contenu, rd.ordre, rd.type, rd.num_note, sujet_action from rapport_demandes rd left join demandes_notes on num_note=id_note left join demandes_actions on num_action=id_action where rd.num_demande='" . $iddemande . "' order by ordre"; $res = mysql_query($req, $dbh); $display = ""; while ($item = mysql_fetch_object($res)) { $titre = substr($item->contenu, 0, 15) . "..."; $style = ""; if (!$item->num_note) { //Ajout manuel switch ($item->type) { case '1': //Titre $style = "style='background-color:#DECDEC' titre='yes'"; $content = $item->contenu; break; case '0': //Commmentaire $content = "* " . $item->contenu; break; } } else { $content = $item->contenu; } $ordre = $item->ordre; if ($item->sujet_action) { $contenu = "<u>" . $item->sujet_action . "</u> : " . $content; } else { $contenu = $content; } $drag = "<span id=\"rap_handle_{$item->id_item}\" style='padding-left:7px' ><img src=\"" . $base_path . "/images/notice_drag.png\" /></span>"; $del = "<span id=\"rap_del_{$item->id_item}\" style='padding-left:7px' onclick='delete_item({$item->id_item});' ><img src=\"" . $base_path . "/images/cross.png\" style='cursor:pointer;width:10px;vertical-align:middle;' /></span>"; $modif = "<span id=\"rap_modif_{$item->id_item}\" style='padding-left:7px;' onclick='modif_item({$item->id_item});' ><img src=\"" . $base_path . "/images/b_edit.png\" style='cursor:pointer;width:10px;vertical-align:middle;'/></span>"; $display .= "\n\t\t\t\t\t<div class='row' {$style} id='rap_drag_{$item->id_item}' draggable=\"yes\" dragtype=\"rapport\" dragtext=\"{$titre}\" dragicon=\"" . $base_path . "/images/icone_drag_notice.png\"\n\t\t\t\t\t\thandler=\"rap_handle_{$item->id_item}\" recepttype=\"rapport\" recept=\"yes\" highlight=\"rap_highlight\" downlight=\"rap_downlight\" iditem='{$item->id_item}' order='{$ordre}'>" . $contenu . $drag . $modif . $del . "</div>\t\t\t\n\t\t\t\t"; } ajax_http_send_response($display); }
function update_order($order, $id) { global $conn, $modul; if ($id) { $sql = "SELECT id, sort_order FROM " . $_SESSION['TABLE_PREFIX'] . $modul . " WHERE sort_order = '" . $order . "' AND id != '" . $id . "' LIMIT 1 "; $result = db_mysql_query($sql, $conn); if (db_mysql_num_rows($result)) { $arr = db_mysql_fetch_array($result); $order++; $sql_upd = "UPDATE " . $_SESSION['TABLE_PREFIX'] . $modul . " SET sort_order = '" . $order . "' WHERE id = '" . $arr['id'] . "' "; db_mysql_query($sql_upd, $conn); update_order($order, $arr['id']); } } }
if ($_GET['action'] == 'execute') { $pid = 1; execute_order($pid); } elseif ($_GET['action'] == 'add') { $pid = $_GET['pid']; $pid = 1; $order_type = $_GET['order_type']; $symbol = $_GET['symbol']; $shares = $_GET['shares']; add_order($pid, $order_type, $symbol, $shares); } elseif ($_GET['action'] == 'delete') { $pid = 1; delete_order($pid, 'BUY', 'AAPL'); } elseif ($_GET['action'] == 'update') { $pid = 1; update_order($pid, 'BUY', 'AAPL', 500); } elseif ($_GET['action'] == 'get_order') { $pid = 1; get_open_order($pid); } elseif ($_GET['action'] == 'get_quote') { $pid = 1; get_yahoo_quote("AAPL+IBM+GS+BAC+FB+WYNN+SZYM+DANG+TSLA+JCP+BIDU+CMG+V+LVS"); } elseif ($_GET['action'] == 'refresh_realtime_quotes') { $pid = 1; refresh_realtime_quotes($a); } } function add_order($pid, $order_type, $symbol, $shares) { global $order_queue; $query = "insert into {$order_queue} (portfolio_id, order_date, order_type, symbol, shares) values ({$pid}, now(), '{$order_type}', '{$symbol}', {$shares}) \n\t\t\t on duplicate key update shares = shares + {$shares}, order_date = now() ";
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); }
$pay_fee = pay_fee($order['pay_id'], $order['order_amount'], $cod_fee); } $order['pay_fee'] = $pay_fee; $order['order_amount'] += $pay_fee; } /* 如果全部支付,设为已确认、已付款 */ if ($order['order_amount'] == 0) { if ($order['order_status'] == OS_UNCONFIRMED) { $order['order_status'] = OS_CONFIRMED; $order['confirm_time'] = gmtime(); } $order['pay_status'] = PS_PAYED; $order['pay_time'] = gmtime(); } $order = addslashes_deep($order); update_order($order_id, $order); /* 更新用户余额 */ $change_desc = sprintf($_LANG['pay_order_by_surplus'], $order['order_sn']); log_account_change($user['user_id'], -1 * $surplus, 0, 0, 0, $change_desc); /* 跳转 */ ecs_header('Location: user.php?act=order_detail&order_id=' . $order_id . "\n"); exit; } elseif ($action == 'act_edit_payment') { /* 检查是否登录 */ if ($_SESSION['user_id'] <= 0) { ecs_header("Location: ./\n"); exit; } /* 检查支付方式 */ $pay_id = intval($_POST['pay_id']); if ($pay_id <= 0) {
} $result['confirm_type'] = !empty($_CFG['cart_confirm']) ? $_CFG['cart_confirm'] : 2; die($json->encode($result)); } elseif ($_REQUEST['step'] == 'pay_code') { //支付宝支付绕过微信屏蔽 $log_id = $_REQUEST['log']; $sql = "SELECT o.*, l.pay_id AS cur_pay_id FROM " . $ecs->table('order_info', o) . ',' . $ecs->table('pay_log', l) . " WHERE o.order_id = l.order_id AND l.log_id = '{$log_id}'"; $order = $db->getRow($sql); //TODO: 检查登录用户 if ($order['order_status'] == OS_UNCONFIRMED && $order['pay_status'] == PS_UNPAYED) { $order_id = $order['order_id']; $pay_id = $order['cur_pay_id']; $payment = payment_info($pay_id); if ($order['pay_id'] != $pay_id) { $order['pay_id'] = $pay_id; update_order($order_id, array('pay_id' => $pay_id, 'pay_name' => $payment['pay_name'])); } $order['log_id'] = $log_id; include_once ROOT_PATH . 'include/modules/payment/' . $payment['pay_code'] . '.php'; $pay_obj = new $payment['pay_code'](); $pay_online = $pay_obj->get_code2($order, unserialize_config($payment['pay_config'])); echo $pay_online; exit; } } else { // 标记购物流程为普通商品 $_SESSION['flow_type'] = CART_GENERAL_GOODS; // 如果是一步购物,跳到结算中心 if ($_CFG['one_step_buy'] == '1') { ecs_header("Location: flow.php?step=checkout\n"); exit;
<?php include "helpers.php"; $songid = $_GET['songid']; $showid = $_GET['showid']; $order = $_GET['order']; update_order($songid, $showid, $order);
<?php // +-------------------------------------------------+ // � 2002-2004 PMB Services / www.sigb.net pmb@sigb.net et contributeurs (voir www.sigb.net) // +-------------------------------------------------+ // $Id: tri.inc.php,v 1.3 2011-08-12 13:50:32 ngantier Exp $ if (stristr($_SERVER['REQUEST_URI'], ".inc.php")) { die("no access"); } switch ($quoifaire) { case 'up_order': update_order(); break; case 'up_order_avis': update_order_avis(); break; } function update_order_avis() { global $dbh, $tablo_avis; $liste_avis = explode(",", $tablo_avis); for ($i = 0; $i < count($liste_avis); $i++) { $rqt = "update avis set avis_rank='" . $i . "' where id_avis='" . $liste_avis[$i] . "' "; mysql_query($rqt, $dbh); } } function update_order() { global $dbh, $idpere, $type_rel, $tablo_fille; $liste_fille = explode(",", $tablo_fille); for ($i = 0; $i < count($liste_fille); $i++) {
/** * 取消一个用户订单 * * @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()); } }
} if ($v['team_status'] == 3) { $sql = "select * from " . $GLOBALS['hhs']->table('order_info') . " where team_sign=" . $v['team_sign']; $team_list = $GLOBALS['db']->getAll($sql); foreach ($team_list as $f) { $order_sn = $f['order_sn']; $r = refund($order_sn, $f['money_paid'] * 100); if ($r) { $arr = array(); $arr['order_status'] = OS_RETURNED; $arr['pay_status'] = PS_REFUNDED; $arr['shipping_status'] = 0; $arr['team_status'] = 3; $arr['money_paid'] = 0; $arr['order_amount'] = $f['money_paid'] + $f['order_amount']; update_order($f['order_id'], $arr); $user_id = $f['user_id']; $wxch_order_name = 'refund'; $team_sign = $f['team_sign']; $order_id = $f['order_id']; require_once ROOT_PATH . 'wxch_order.php'; } } } } } /**/ /**/ $smarty->assign('menus', $menus); $smarty->assign('no_help', $_LANG['no_help']); $smarty->assign('help_lang', $_CFG['lang']);
if (empty($pids)) { echo json_encode(array('errcode' => 10, 'msg' => '没有可以取货的商品')); exit; } // 获取商品 $goods = get_pickup_goods($pids); if (empty($goods)) { echo json_encode(array('errcode' => 10, 'msg' => '没有可以取货的商品')); exit; } // Update order status $orders = get_pickup_orders($pids); if (!empty($orders)) { $status = array('shipping_status' => SS_RECEIVED, 'receive_time' => time()); foreach ($orders as &$o) { update_order($o['order_id'], $status); order_action($o['order_sn'], OS_CONFIRMED, SS_RECEIVED, PS_PAYED, '门店取货'); } } // Update package status $sql = "UPDATE " . $ecs->table('pickup_pack') . " SET status=3 WHERE id IN (" . implode(',', $pids) . ")"; $db->query($sql); $response = array('errcode' => 0, 'mobile' => $orders[0]['mobile'], 'goods' => $goods, 'orders' => $orders, 'packs' => $packs); echo json_encode($response); exit; } $smarty->display(is_wechat_browser() ? 'pickup_wechat.htm' : 'pickup_wechat.htm'); /** * 检查取货码,返回对应的user_id * * @param string $code 取货码
// 0,为已发货 $query = $db->autoExecute($hhs->table('delivery_order'), $_delivery, 'UPDATE', "delivery_id = {$delivery_id}", 'SILENT'); if (!$query) { /* 操作失败 */ $links[] = array('text' => $_LANG['delivery_sn'] . $_LANG['detail'], 'href' => 'order.php?act=delivery_info&delivery_id=' . $delivery_id); sys_msg($_LANG['act_false'], 1, $links); } /* 标记订单为已确认 “已发货” */ /* 更新发货时间 */ $order_finish = get_all_delivery_finish($order_id); $shipping_status = $order_finish == 1 ? SS_SHIPPED : SS_SHIPPED_PART; $arr['shipping_status'] = $shipping_status; $arr['shipping_time'] = GMTIME_UTC; // 发货时间 //$arr['invoice_no'] = $invoice_no;//trim($order['invoice_no'] . '<br>' . $invoice_no, '<br>'); update_order($order_id, $arr); $user_id = $order['user_id']; $wxch_order_name = 'shipping'; include_once '../wxch_order.php'; /* 发货单发货记录log */ order_action($order['order_sn'], OS_CONFIRMED, $shipping_status, $order['pay_status'], $action_note, null, 1); /* 如果当前订单已经全部发货 */ if ($order_finish) { /* 如果订单用户不为空,计算积分,并发给用户;发优惠劵 */ 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'])); /* 发放优惠劵
/* -- INSPIRATION FETURED -- */ // PREDEFINED VALUE $param = $max_id; delete_inspiration_featured($inspiration['inspiration_id']); $feat = $_POST['product_featured']; foreach($feat as $feat){ insert_inspiration_featured($inspiration['inspiration_id'], $feat, 1, 1); } // ORDER DRAGABLE foreach($sort as $key=>$order){ $slide_id = (int) $key + 1; update_order($slide_id, $order); } // ALERT $_SESSION['alert'] = "success"; $_SESSION['msg'] = "Item has been successfully added."; } ?>
$os = array('order_status' => OS_CONFIRMED, 'shipping_status' => SS_PREPARING, 'confirm_time' => $now); // 生成包裹 $shop_id = 0; $user_id = 0; while ($o = $db->fetch_array($query)) { if ($o['shop_id'] != $shop_id || $o['user_id'] != $user_id) { $shop_id = $o['shop_id']; $user_id = $o['user_id']; $pickup_time = get_order_pickup_time($locktime, 0, $o['open_time'], $o['close_time']); $pack_obj = array('shop_id' => $shop_id, 'user_id' => $user_id, 'start_time' => $pickup_time['start'], 'end_time' => $pickup_time['end'], 'expire_time' => $pickup_time['start'] + 3600 * intval($_CFG['shipping_limit_time']), 'create_date' => date('Ymd', $pickup_time['start'])); $db->autoExecute($ecs->table('pickup_pack'), $pack_obj); $pack_id = $db->insert_id(); } // 更新订单状态 $os['package_id'] = $pack_id; update_order($o['order_id'], $os); // 计算并发放积分 //$integral = integral_to_give($o); //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($o['order_id']); } // 规划包裹位置 $pack_date = date('Ymd', $pickup_time['start']); $sql = "SELECT shop_id, count(id) AS pack_num FROM " . $ecs->table('pickup_pack') . " WHERE create_date = '{$pack_date}' GROUP BY shop_id"; $query = $db->query($sql); while ($shop = $db->fetch_array($query)) { $sql = "SELECT id FROM " . $ecs->table('pickup_pack') . " WHERE create_date = '{$pack_date}' AND shop_id = '{$shop['shop_id']}' ORDER BY user_id ASC"; $pack_list = $db->getCol($sql); $pack_num = $shop['pack_num']; $num_per_row = floor($pack_num / SHELF_ROW_NUM);
/** * 变更订单的发货状态 * * @access private * @param string $brand_name * @return array */ function pos_order_shipping($order_id) { if (!check_priviege()) { exit; } $operation = 'ship'; /* 查询订单信息 */ $order = order_info($order_id); /* 检查能否操作 */ $operable_list = operable_list($order); if (!isset($operable_list[$operation])) { die('Hacking attempt'); } if ($order['order_status'] != OS_CONFIRMED) { $post['order_status'] = OS_CONFIRMED; $post['confirm_time'] = gmtime(); } $post['shipping_status'] = SS_SHIPPED; $post['shipping_time'] = gmtime(); update_order($order_id, $post); $action_note = '[OrderHelper ' . TUNNELVERSION . '] 打印快递单'; /* 记录log */ order_action($order['order_sn'], OS_CONFIRMED, SS_SHIPPED, $order['pay_status'], $action_note); }
/** * 處理函數 */ function respond() { $arPayment = get_payment('ecshop_allpay_atm'); $isTestMode = $arPayment['ecshop_allpay_atm_test_mode'] == 'Yes'; $arFeedback = null; $arQueryFeedback = null; $szLogID = $_GET['log_id']; $szOrderID = $_GET['order_id']; //$isPaymentInfo = ($_GET['pi'] == 'true'); $this->HashKey = trim($arPayment['ecshop_allpay_atm_key']); $this->HashIV = trim($arPayment['ecshop_allpay_atm_iv']); try { // 取得回傳的付款結果。 $arFeedback = $this->CheckOutFeedback(); if (sizeof($arFeedback) > 0) { // 查詢付款結果資料。 $this->ServiceURL = $isTestMode ? "https://payment-stage.allpay.com.tw/Cashier/QueryTradeInfo/v2" : "https://payment.allpay.com.tw/Cashier/QueryTradeInfo/V2"; $this->MerchantID = trim($arPayment['ecshop_allpay_atm_account']); $this->Query['MerchantTradeNo'] = $arFeedback['MerchantTradeNo']; $arQueryFeedback = $this->QueryTradeInfo(); if (sizeof($arQueryFeedback) > 0) { $arOrder = order_info($szOrderID); // 檢查支付金額與訂單是否相符。 if (round($arOrder['order_amount']) == $arFeedback['TradeAmt'] && $arQueryFeedback['TradeAmt'] == $arFeedback['TradeAmt']) { $szCheckAmount = '1'; } // 確認產生虛擬帳號。 if ($arFeedback['RtnCode'] == '2' && $szCheckAmount == '1' && $arQueryFeedback["TradeStatus"] == '0') { $szPaymentType = $arFeedback['PaymentType']; $szTradeDate = $arFeedback['TradeDate']; $szBankCode = $arFeedback['BankCode']; $szVirtualAccount = $arFeedback['vAccount']; $szExpireDate = $arFeedback['ExpireDate']; $szNote = sprintf($GLOBALS['_LANG']['text_paying'], date("Y-m-d H:i:s"), $szPaymentType, $szTradeDate, $szBankCode, $szVirtualAccount, $szExpireDate); // 變更訂單狀態為已確認 update_order($szOrderID, array('order_status' => OS_CONFIRMED, 'confirm_time' => gmtime())); // 將付款資訊記入操作訊息 order_action($arOrder['order_sn'], OS_CONFIRMED, $arOrder['shipping_status'], $arOrder['pay_status'], $szNote); ob_get_clean(); print '1|OK'; exit; } // 確認付款結果。 if ($arFeedback['RtnCode'] == '1' && $szCheckAmount == '1' && $arQueryFeedback["TradeStatus"] == '1') { $szNote = $GLOBALS['_LANG']['text_paid'] . date("Y-m-d H:i:s"); order_paid($szLogID, PS_PAYED, $szNote); if ($_GET['background']) { echo '1|OK'; exit; } else { return true; } } else { if ($_GET['background']) { echo !$szCheckAmount ? '0|訂單金額不符。' : $arFeedback['RtnMsg']; exit; } else { return false; } } } else { throw new Exception('AllPay 查無訂單資料。'); } } } catch (Exception $ex) { /* 例外處理 */ } return false; }
/** * 处理编辑订单时订单金额变动 * @param array $order 订单信息 * @param array $msgs 提示信息 * @param array $links 链接信息 */ function handle_order_money_change($order, &$msgs, &$links) { $order_id = $order['order_id']; if ($order['pay_status'] == PS_PAYED || $order['pay_status'] == PS_PAYING) { /* 应付款金额 */ $money_dues = $order['order_amount']; if ($money_dues > 0) { /* 修改订单为未付款 */ update_order($order_id, array('pay_status' => PS_UNPAYED, 'pay_time' => 0)); $msgs[] = $GLOBALS['_LANG']['amount_increase']; $links[] = array('text' => $GLOBALS['_LANG']['order_info'], 'href' => 'order.php?act=info&order_id=' . $order_id); } elseif ($money_dues < 0) { $anonymous = $order['user_id'] > 0 ? 0 : 1; $msgs[] = $GLOBALS['_LANG']['amount_decrease']; $links[] = array('text' => $GLOBALS['_LANG']['refund'], 'href' => 'order.php?act=process&func=load_refund&anonymous=' . $anonymous . '&order_id=' . $order_id . '&refund_amount=' . abs($money_dues)); } } }
/** * 添加/编辑预售活动的提交 */ function action_insert_update() { $user = $GLOBALS['user']; $_CFG = $GLOBALS['_CFG']; $_LANG = $GLOBALS['_LANG']; $smarty = $GLOBALS['smarty']; $db = $GLOBALS['db']; $ecs = $GLOBALS['ecs']; $user_id = $_SESSION['user_id']; /* 取得预售活动id */ $pre_sale_id = intval($_POST['act_id']); if (isset($_POST['finish']) || isset($_POST['succeed']) || isset($_POST['fail']) || isset($_POST['mail'])) { if ($pre_sale_id <= 0) { sys_msg($_LANG['error_pre_sale'], 1); } $pre_sale = pre_sale_info($pre_sale_id); if (empty($pre_sale)) { sys_msg($_LANG['error_pre_sale'], 1); } } if (isset($_POST['finish'])) { /* 设置活动结束 */ /* 判断活动状态 */ if ($pre_sale['status'] != PSS_UNDER_WAY) { sys_msg($_LANG['error_status'], 1); // 此处怀疑是如果活动进行中突然要结束掉,应该抛出禁止的页面,貌似去掉了,所以程序继续执行 } /* 结束预售活动,修改结束时间为当前时间 */ $sql = "UPDATE " . $ecs->table('goods_activity') . " SET end_time = '" . gmtime() . "' " . "WHERE act_id = '{$pre_sale_id}' LIMIT 1"; $db->query($sql); /* 清除缓存 */ clear_cache_files(); /* 提示信息 */ $links = array(array('href' => 'pre_sale.php?act=list', 'text' => $_LANG['back_list'])); sys_msg($_LANG['edit_success'], 0, $links); } elseif (isset($_POST['succeed'])) { /* 设置活动成功 */ /* 判断订单状态 */ if ($pre_sale['status'] != PSS_FINISHED) { sys_msg($_LANG['error_status'], 1); } /* 如果有订单,更新订单信息 */ if ($pre_sale['total_order'] > 0) { /* 查找该预售活动的已确认或未确认订单(已取消的就不管了) */ $sql = "SELECT order_id " . "FROM " . $ecs->table('order_info') . " WHERE extension_code = '" . PRE_SALE_CODE . "' " . "AND extension_id = '{$pre_sale_id}' " . "AND (order_status = '" . OS_CONFIRMED . "' or order_status = '" . OS_UNCONFIRMED . "')"; $order_id_list = $db->getCol($sql); /* 更新订单商品价 */ $final_price = $pre_sale['trans_price']; $sql = "UPDATE " . $ecs->table('order_goods') . " SET goods_price = '{$final_price}' " . "WHERE order_id " . db_create_in($order_id_list); $db->query($sql); /* 查询订单商品总额 */ $sql = "SELECT order_id, SUM(goods_number * goods_price) AS goods_amount " . "FROM " . $ecs->table('order_goods') . " WHERE order_id " . db_create_in($order_id_list) . " GROUP BY order_id"; $res = $db->query($sql); while ($row = $db->fetchRow($res)) { $order_id = $row['order_id']; $goods_amount = floatval($row['goods_amount']); /* 取得订单信息 */ $order = order_info($order_id); /* 判断订单是否有效:余额支付金额 + 已付款金额 >= 保证金 */ if ($order['surplus'] + $order['money_paid'] >= $pre_sale['deposit']) { /* 有效,设为已确认,更新订单 */ // 更新商品总额 $order['goods_amount'] = $goods_amount; // 如果保价,重新计算保价费用 if ($order['insure_fee'] > 0) { $shipping = shipping_info($order['shipping_id']); $order['insure_fee'] = shipping_insure_fee($shipping['shipping_code'], $goods_amount, $shipping['insure']); } // 重算支付费用 $order['order_amount'] = $order['goods_amount'] + $order['shipping_fee'] + $order['insure_fee'] + $order['pack_fee'] + $order['card_fee'] - $order['money_paid'] - $order['surplus']; if ($order['order_amount'] > 0) { $order['pay_fee'] = pay_fee($order['pay_id'], $order['order_amount']); } else { $order['pay_fee'] = 0; } // 计算应付款金额 $order['order_amount'] += $order['pay_fee']; // 计算付款状态 if ($order['order_amount'] > 0) { $order['pay_status'] = PS_UNPAYED; $order['pay_time'] = 0; } else { $order['pay_status'] = PS_PAYED; $order['pay_time'] = gmtime(); } // 如果需要退款,退到帐户余额 if ($order['order_amount'] < 0) { // todo (现在手工退款) } // 订单状态 $order['order_status'] = OS_CONFIRMED; $order['confirm_time'] = gmtime(); // 更新订单 $order = addslashes_deep($order); update_order($order_id, $order); } else { /* 无效,取消订单,退回已付款 */ // 修改订单状态为已取消,付款状态为未付款 $order['order_status'] = OS_CANCELED; $order['to_buyer'] = $_LANG['cancel_order_reason']; $order['pay_status'] = PS_UNPAYED; $order['pay_time'] = 0; /* 如果使用余额或有已付款金额,退回帐户余额 */ $money = $order['surplus'] + $order['money_paid']; if ($money > 0) { $order['surplus'] = 0; $order['money_paid'] = 0; $order['order_amount'] = $money; // 退款到帐户余额 order_refund($order, 1, $_LANG['cancel_order_reason'] . ':' . $order['order_sn']); } /* 更新订单 */ $order = addslashes_deep($order); update_order($order['order_id'], $order); } } } /* 修改预售活动状态为成功 */ $sql = "UPDATE " . $ecs->table('goods_activity') . " SET is_finished = '" . PSS_SUCCEED . "' " . "WHERE act_id = '{$pre_sale_id}' LIMIT 1"; $db->query($sql); /* 清除缓存 */ clear_cache_files(); /* 提示信息 */ $links = array(array('href' => 'pre_sale.php?act=list', 'text' => $_LANG['back_list'])); sys_msg($_LANG['edit_success'], 0, $links); } elseif (isset($_POST['fail'])) { /* 设置活动失败 */ /* 判断订单状态 */ if ($pre_sale['status'] != PSS_FINISHED) { sys_msg($_LANG['error_status'], 1); } /* 如果有有效订单,取消订单 */ if ($pre_sale['valid_order'] > 0) { /* 查找未确认或已确认的订单 */ $sql = "SELECT * " . "FROM " . $ecs->table('order_info') . " WHERE extension_code = '" . PRE_SALE_CODE . "' " . "AND extension_id = '{$pre_sale_id}' " . "AND (order_status = '" . OS_CONFIRMED . "' OR order_status = '" . OS_UNCONFIRMED . "') "; $res = $db->query($sql); while ($order = $db->fetchRow($res)) { // 修改订单状态为已取消,付款状态为未付款 $order['order_status'] = OS_CANCELED; $order['to_buyer'] = $_LANG['cancel_order_reason']; $order['pay_status'] = PS_UNPAYED; $order['pay_time'] = 0; /* 如果使用余额或有已付款金额,退回帐户余额 */ $money = $order['surplus'] + $order['money_paid']; if ($money > 0) { $order['surplus'] = 0; $order['money_paid'] = 0; $order['order_amount'] = $money; // 退款到帐户余额 order_refund($order, 1, $_LANG['cancel_order_reason'] . ':' . $order['order_sn'], $money); } /* 更新订单 */ $order = addslashes_deep($order); update_order($order['order_id'], $order); } } /* 修改预售活动状态为失败,记录失败原因(活动说明) */ $sql = "UPDATE " . $ecs->table('goods_activity') . " SET is_finished = '" . PSS_FAIL . "', " . "act_desc = '{$_POST['act_desc']}' " . "WHERE act_id = '{$pre_sale_id}' LIMIT 1"; $db->query($sql); /* 清除缓存 */ clear_cache_files(); /* 提示信息 */ $links = array(array('href' => 'pre_sale.php?act=list', 'text' => $_LANG['back_list'])); sys_msg($_LANG['edit_success'], 0, $links); } elseif (isset($_POST['mail'])) { /* 发送通知邮件 */ /* 判断订单状态 */ if ($pre_sale['status'] != PSS_SUCCEED) { sys_msg($_LANG['error_status'], 1); } /* 取得邮件模板 */ $tpl = get_mail_template('pre_sale'); /* 初始化订单数和成功发送邮件数 */ $count = 0; $send_count = 0; /* 取得有效订单 */ $sql = "SELECT o.consignee, o.add_time, g.goods_number, o.order_sn, " . "o.order_amount, o.order_id, o.email " . "FROM " . $ecs->table('order_info') . " AS o, " . $ecs->table('order_goods') . " AS g " . "WHERE o.order_id = g.order_id " . "AND o.extension_code = '" . PRE_SALE_CODE . "' " . "AND o.extension_id = '{$pre_sale_id}' " . "AND o.order_status = '" . OS_CONFIRMED . "'"; $res = $db->query($sql); while ($order = $db->fetchRow($res)) { /* 邮件模板赋值 */ $smarty->assign('consignee', $order['consignee']); $smarty->assign('add_time', local_date($_CFG['time_format'], $order['add_time'])); $smarty->assign('goods_name', $pre_sale['goods_name']); $smarty->assign('goods_number', $order['goods_number']); $smarty->assign('order_sn', $order['order_sn']); $smarty->assign('order_amount', price_format($order['order_amount'])); $smarty->assign('shop_url', $ecs->url() . 'user.php?act=order_detail&order_id=' . $order['order_id']); $smarty->assign('shop_name', $_CFG['shop_name']); $smarty->assign('send_date', local_date($_CFG['date_format'])); /* 取得模板内容,发邮件 */ $content = $smarty->fetch('str:' . $tpl['template_content']); if (send_mail($order['consignee'], $order['email'], $tpl['template_subject'], $content, $tpl['is_html'])) { $send_count++; } $count++; } /* 提示信息 */ sys_msg(sprintf($_LANG['mail_result'], $count, $send_count)); } else { /* 保存预售信息 */ $goods_id = intval($_POST['goods_id']); if ($goods_id <= 0) { sys_msg($_LANG['error_goods_null']); } $info = goods_pre_sale($goods_id); if ($info && $info['act_id'] != $pre_sale_id) { sys_msg($_LANG['error_goods_exist']); } $goods_name = $db->getOne("SELECT goods_name FROM " . $ecs->table('goods') . " WHERE goods_id = '{$goods_id}'"); $act_name = empty($_POST['act_name']) ? $goods_name : sub_str($_POST['act_name'], 0, 255, false); // 预售价格 $sale_price = floatval($_POST['sale_price']); if ($sale_price < 0) { $sale_price = 0; } // 定金 $deposit = floatval($_POST['deposit']); if ($deposit < 0) { $deposit = 0; } // 限购数量 $restrict_amount = intval($_POST['restrict_amount']); if ($restrict_amount < 0) { $restrict_amount = 0; } // 赠送积分 $gift_integral = intval($_POST['gift_integral']); if ($gift_integral < 0) { $gift_integral = 0; } $price_ladder = array(); $count = count($_POST['ladder_amount']); for ($i = $count - 1; $i >= 0; $i--) { /* 如果数量小于等于0,不要 */ $amount = intval($_POST['ladder_amount'][$i]); if ($amount <= 0) { continue; } /* 如果价格小于等于0,不要 */ $price = round(floatval($_POST['ladder_price'][$i]), 2); if ($price <= 0) { continue; } /* 加入价格阶梯 */ $price_ladder[$amount] = array('amount' => $amount, 'price' => $price); } if (count($price_ladder) < 1) { sys_msg($_LANG['error_price_ladder']); } /* 限购数量不能小于价格阶梯中的最大数量 */ $amount_list = array_keys($price_ladder); if ($restrict_amount > 0 && max($amount_list) > $restrict_amount) { sys_msg($_LANG['error_restrict_amount']); } ksort($price_ladder); $price_ladder = array_values($price_ladder); /* 检查开始时间和结束时间是否合理 */ $start_time = local_strtotime($_POST['start_time']); $end_time = local_strtotime($_POST['end_time']); if ($start_time >= $end_time) { // $_LANG['invalid_time'] sys_msg('您输入了一个无效的时间,活动结束时间不能早于活动开始时间!'); } if ($deposit > 0) { $retainage_start = local_strtotime($_POST['retainage_start']); $retainage_end = local_strtotime($_POST['retainage_end']); /* 检查活动结束时间和尾款开始支付时间是否合理 */ if ($end_time >= $retainage_start) { // $_LANG['invalid_time'] sys_msg('您输入了一个无效的时间,尾款开始支付时间不能早于活动结束时间!'); } /* 检查尾款支付开始时间和结束时间是否合理 */ if ($retainage_start >= $retainage_end) { // $_LANG['invalid_time'] sys_msg('您输入了一个无效的时间,尾款结束支付时间不能早于尾款开始支付时间!'); } } else { $retainage_start = ''; $retainage_end = ''; } // 预计发货时间描述 $deliver_goods = $_POST['deliver_goods']; $pre_sale = array('act_name' => $act_name, 'act_desc' => $_POST['act_desc'], 'act_type' => GAT_PRE_SALE, 'goods_id' => $goods_id, 'goods_name' => $goods_name, 'start_time' => $start_time, 'end_time' => $end_time, 'ext_info' => serialize(array('sale_price' => $sale_price, 'retainage_start' => $retainage_start, 'retainage_end' => $retainage_end, 'price_ladder' => $price_ladder, 'restrict_amount' => $restrict_amount, 'gift_integral' => $gift_integral, 'deposit' => $deposit, 'deliver_goods' => $deliver_goods))); // 开始发货时间描述 /* 清除缓存 */ clear_cache_files(); /* 保存数据 */ if ($pre_sale_id > 0) { /* update */ $db->autoExecute($ecs->table('goods_activity'), $pre_sale, 'UPDATE', "act_id = '{$pre_sale_id}'"); /* log */ admin_log(addslashes($goods_name) . '[' . $pre_sale_id . ']', 'edit', 'pre_sale'); /* todo 更新活动表 */ /* 提示信息 */ $links = array(array('href' => 'pre_sale.php?act=list&' . list_link_postfix(), 'text' => $_LANG['back_list'])); sys_msg($_LANG['edit_success'], 0, $links); } else { /* insert */ $db->autoExecute($ecs->table('goods_activity'), $pre_sale, 'INSERT'); /* log */ admin_log(addslashes($goods_name), 'add', 'pre_sale'); /* 提示信息 */ $links = array(array('href' => 'pre_sale.php?act=add', 'text' => $_LANG['continue_add']), array('href' => 'pre_sale.php?act=list', 'text' => $_LANG['back_list'])); sys_msg($_LANG['add_success'], 0, $links); } } }
$order['order_status'] = OS_CANCELED; $order['to_buyer'] = $_LANG['cancel_order_reason']; $order['pay_status'] = PS_UNPAYED; $order['pay_time'] = 0; /* 如果使用余额或有已付款金额,退回帐户余额 */ $money = $order['surplus'] + $order['money_paid']; if ($money > 0) { $order['surplus'] = 0; $order['money_paid'] = 0; $order['order_amount'] = $money; // 退款到帐户余额 order_refund($order, 1, $_LANG['cancel_order_reason'] . ':' . $order['order_sn'], $money); } /* 更新订单 */ $order = addslashes_deep($order); update_order($order['order_id'], $order); } } /* 修改团购活动状态为失败,记录失败原因(活动说明) */ $sql = "UPDATE " . $ecs->table('goods_activity') . " SET is_finished = '" . GBS_FAIL . "', " . "act_desc = '{$_POST['act_desc']}' " . "WHERE act_id = '{$group_buy_id}' LIMIT 1"; $db->query($sql); /* 清除缓存 */ clear_cache_files(); /* 提示信息 */ $links = array(array('href' => 'group_buy.php?act=list', 'text' => $_LANG['back_list'])); sys_msg($_LANG['edit_success'], 0, $links); } elseif (isset($_POST['mail'])) { /* 发送通知邮件 */ /* 判断订单状态 */ if ($group_buy['status'] != GBS_SUCCEED) { sys_msg($_LANG['error_status'], 1);
echo "id=\"link-category-" . $new_parent . "\">"; for ($i = 0; $i < $level; $i++) { echo '-- '; } echo ucwords(strtolower($cat_name)) . "</a></td>"; echo "<td class=\"tr\"><a href=\"\">" . $get_data_array['total_product'] . "</a></td>"; echo "<td>" . $cat_active . "</td>"; echo "<td>" . $cat_visibility . "</td>"; echo "</tr>"; $new_row = $row * 1 + 1; showCategory($new_level, $new_parent, $current_category, $one, $two, $three, $four, $tot_query, $new_row); } } } if (isset($_POST['btn_child_category'])) { $category_id = $_POST['category_id']; if ($_POST['category-action'] == "delete") { foreach ($category_id as $category_id) { delete_category($category_id); } } else { if ($_POST['category-action'] == "order") { $hidden_id = $_POST['hidden_category_id']; foreach ($hidden_id as $key => $category_id) { update_order($key, $category_id); } $_SESSION['alert'] = 'success'; $_SESSION['msg'] = 'Changes has been successfully saved.'; } } }
function pay_team_action($orsn) { /*是团购改变订单*/ $sql = "select * from " . $GLOBALS['hhs']->table('order_info') . " where order_sn='" . $orsn . "'"; $order_info = $GLOBALS['db']->getRow($sql); include_once ROOT_PATH . "languages/zh_cn/wx_msg.php"; if (!empty($order_info) && $order_info['extension_code'] == 'team_goods') { $team_sign = $order_info['team_sign']; $weixin = new class_weixin($GLOBALS['appid'], $GLOBALS['appsecret']); $openid = $GLOBALS['db']->getOne("select openid from " . $GLOBALS['hhs']->table('users') . " where user_id=" . $order_info['user_id']); $t_openid = $GLOBALS['db']->getOne("select u.openid from " . $GLOBALS['hhs']->table('order_info') . " as oi left join " . $GLOBALS['hhs']->table('users') . " as u on oi.user_id=u.user_id where oi.team_first=1 and oi.team_sign=" . $team_sign); $sql = "select team_num,discount_type,discount_amount from " . $GLOBALS['hhs']->table('goods') . " where goods_id=" . $order_info['extension_id']; $rs = $GLOBALS['db']->getRow($sql); $team_num = $rs['team_num']; $discount_type = $rs['discount_type']; $discount_amount = $rs['discount_amount']; if ($order_info['team_first'] == 1) { //若是团长记录下团的人数 if ($discount_type == 1 && $order_info['refund_sign'] == 0) { $sql = "UPDATE " . $GLOBALS['hhs']->table('order_info') . " SET team_num='{$team_num}',discount_type ='{$discount_type}',discount_amount=money_paid+order_amount WHERE order_id=" . $order_info['order_id']; } elseif ($discount_type == 2 && $order_info['refund_sign'] == 0) { $sql = "UPDATE " . $GLOBALS['hhs']->table('order_info') . " SET team_num='{$team_num}',discount_type ='{$discount_type}', discount_amount='{$discount_amount}' WHERE order_id=" . $order_info['order_id']; } else { $sql = "UPDATE " . $GLOBALS['hhs']->table('order_info') . " SET team_num='{$team_num}', discount_amount=0 WHERE order_id=" . $order_info['order_id']; } $GLOBALS['db']->query($sql); } $sql = "select team_num from " . $GLOBALS['hhs']->table('order_info') . " where order_id=" . $order_info['team_sign']; $team_num = $GLOBALS['db']->getOne($sql); //团共需人数和状态 $sql = "UPDATE " . $GLOBALS['hhs']->table('order_info') . " SET team_status=1,team_num='{$team_num}' WHERE order_id=" . $order_info['order_id']; $GLOBALS['db']->query($sql); //实际人数 $sql = "select count(*) from " . $GLOBALS['hhs']->table('order_info') . " where team_sign=" . $team_sign . " and team_status>0 "; $rel_num = $GLOBALS['db']->getOne($sql); //存储实际人数 $sql = "update " . $GLOBALS['hhs']->table('order_info') . " set teammen_num='{$rel_num}' where team_sign=" . $team_sign; $GLOBALS['db']->query($sql); if ($team_num <= $rel_num) { $sql = "UPDATE " . $GLOBALS['hhs']->table('order_info') . " SET team_status=2 WHERE team_status=1 and team_sign=" . $team_sign; $GLOBALS['db']->query($sql); //取消未参团订单 $sql = "UPDATE " . $GLOBALS['hhs']->table('order_info') . " SET order_status=2 WHERE team_status=0 and team_sign=" . $team_sign; $GLOBALS['db']->query($sql); //判断团长是否有优惠,要重新取数据 $sql = "select order_id,user_id,refund_sign,discount_type, discount_amount, money_paid,order_amount,order_sn from " . $GLOBALS['hhs']->table('order_info') . " where order_id=" . $team_sign; $r = $GLOBALS['db']->getRow($sql); //目前只有微信可以退款 $payment = payment_info($order_info['pay_id']); if ($payment['pay_code'] == 'wxpay') { if ($r['discount_type'] == 1 && $r['refund_sign'] == 0) { //团长免单 $f = refund($r['order_sn'], $r['money_paid'] * 100); if ($f) { $arr['pay_status'] = 3; $arr['refund_sign'] = 1; $arr['money_paid'] = 0; $arr['order_amount'] = $r['money_paid'] + $r['order_amount']; update_order($team_sign, $arr); $weixin->send_wxmsg($t_openid, $_team_msg['refund_team_first']['title'], 'share.php?team_sign=' . $team_sign, $_team_msg['refund_team_first']['desc']); } } elseif ($r['discount_type'] == 2 && $r['refund_sign'] == 0) { $f = refund($r['order_sn'], $r['discount_amount'] * 100); if ($f) { $arr['refund_sign'] = 1; $arr['money_paid'] = $r['money_paid'] - $r['discount_amount']; $arr['order_amount'] = $r['discount_amount'] + $r['order_amount']; update_order($team_sign, $arr); $weixin->send_wxmsg($t_openid, $_team_msg['refund_team_discount']['title'], 'share.php?team_sign=' . $team_sign, $_team_msg['refund_team_discount']['desc']); } } } } if ($order_info['team_first'] == 1) { $weixin->send_wxmsg($openid, $_team_msg['pay']['title'], 'share.php?team_sign=' . $team_sign, $_team_msg['pay']['desc']); //$weixin->send_wxmsg($t_openid, $_team_msg['team_suc_first']['title'] , 'share.php?team_sign='.$team_sign , $_team_msg['team_suc_first']['title'] ); } elseif ($order_info['team_first'] == 2) { if ($team_num <= $rel_num) { $weixin->send_wxmsg($openid, $_team_msg['team_suc_mem']['title'], 'share.php?team_sign=' . $team_sign, $_team_msg['team_suc_mem']['desc']); $weixin->send_wxmsg($t_openid, $_team_msg['team_suc_first']['title'], 'share.php?team_sign=' . $team_sign, $_team_msg['team_suc_first']['title']); } else { $weixin->send_wxmsg($openid, $_team_msg['mem_pay']['title'], 'share.php?team_sign=' . $team_sign, $_team_msg['mem_pay']['title']); } } } }
/* 如果订单金额为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); $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())); /* 如果订单用户不为空,计算积分,并发给用户;发红包 */ 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']); } } } } } /* 清空购物车 */
/** * 取消一个用户订单 * * @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; } }
/** * 删除发货单时删除其在订单中的发货单号 * * @access public * @param int $order_id 定单id * @param string $delivery_invoice_no 发货单号 * * @return void */ function del_order_invoice_no($order_id, $delivery_invoice_no) { /* 查询:取得订单中的发货单号 */ $sql = "SELECT invoice_no\n FROM " . $GLOBALS['ecs']->table('order_info') . "\n WHERE order_id = '{$order_id}'"; $order_invoice_no = $GLOBALS['db']->getOne($sql); /* 如果为空就结束处理 */ if (empty($order_invoice_no)) { return; } /* 去除当前发货单号 */ $order_array = explode('<br>', $order_invoice_no); $delivery_array = explode('<br>', $delivery_invoice_no); foreach ($order_array as $key => $invoice_no) { if ($ii = array_search($invoice_no, $delivery_array)) { unset($order_array[$key], $delivery_array[$ii]); } } $arr['invoice_no'] = implode('<br>', $order_array); update_order($order_id, $arr); }
function actionPaypalCancel($token) { if ($token) { update_order('status', 'Cancelled', $token); } }
function action_act_edit_surplus() { $user = $GLOBALS['user']; $_CFG = $GLOBALS['_CFG']; $_LANG = $GLOBALS['_LANG']; $smarty = $GLOBALS['smarty']; $db = $GLOBALS['db']; $ecs = $GLOBALS['ecs']; $user_id = $_SESSION['user_id']; /* 检查是否登录 */ if ($_SESSION['user_id'] <= 0) { ecs_header("Location: ./\n"); exit; } /* 检查订单号 */ $order_id = intval($_POST['order_id']); if ($order_id <= 0) { ecs_header("Location: ./\n"); exit; } /* 检查余额 */ $surplus = floatval($_POST['surplus']); if ($surplus <= 0) { $err->add($_LANG['error_surplus_invalid']); $err->show($_LANG['order_detail'], 'user.php?act=order_detail&order_id=' . $order_id); } include_once ROOT_PATH . 'includes/lib_order.php'; /* 取得订单 */ $order = order_info($order_id); if (empty($order)) { ecs_header("Location: ./\n"); exit; } /* 检查订单用户跟当前用户是否一致 */ if ($_SESSION['user_id'] != $order['user_id']) { ecs_header("Location: ./\n"); exit; } /* 检查订单是否未付款,检查应付款金额是否大于0 */ if ($order['pay_status'] != PS_UNPAYED || $order['order_amount'] <= 0) { $err->add($_LANG['error_order_is_paid']); $err->show($_LANG['order_detail'], 'user.php?act=order_detail&order_id=' . $order_id); } /* 计算应付款金额(减去支付费用) */ $order['order_amount'] -= $order['pay_fee']; /* 余额是否超过了应付款金额,改为应付款金额 */ if ($surplus > $order['order_amount']) { $surplus = $order['order_amount']; } /* 取得用户信息 */ $user = user_info($_SESSION['user_id']); /* 用户帐户余额是否足够 */ if ($surplus > $user['user_money'] + $user['credit_line']) { $err->add($_LANG['error_surplus_not_enough']); $err->show($_LANG['order_detail'], 'user.php?act=order_detail&order_id=' . $order_id); } /* 修改订单,重新计算支付费用 */ $order['surplus'] += $surplus; $order['order_amount'] -= $surplus; if ($order['order_amount'] > 0) { $cod_fee = 0; if ($order['shipping_id'] > 0) { $regions = array($order['country'], $order['province'], $order['city'], $order['district']); $shipping = shipping_area_info($order['shipping_id'], $regions); if ($shipping['support_cod'] == '1') { $cod_fee = $shipping['pay_fee']; } } $pay_fee = 0; if ($order['pay_id'] > 0) { $pay_fee = pay_fee($order['pay_id'], $order['order_amount'], $cod_fee); } $order['pay_fee'] = $pay_fee; $order['order_amount'] += $pay_fee; } /* 如果全部支付,设为已确认、已付款 */ if ($order['order_amount'] == 0) { if ($order['order_status'] == OS_UNCONFIRMED) { $order['order_status'] = OS_CONFIRMED; $order['confirm_time'] = gmtime(); } $order['pay_status'] = PS_PAYED; $order['pay_time'] = gmtime(); } $order = addslashes_deep($order); update_order($order_id, $order); /* 更新用户余额 */ $change_desc = sprintf($_LANG['pay_order_by_surplus'], $order['order_sn']); log_account_change($user['user_id'], -1 * $surplus, 0, 0, 0, $change_desc); /* 跳转 */ ecs_header('Location: user.php?act=order_detail&order_id=' . $order_id . "\n"); exit; }
/** * 提交函数 */ function get_code($order, $payment) { //include_once(ROOT_PATH.'includes/iconv/cls_iconv.php'); //$iconv = new Chinese(ROOT_PATH); $c_mid = trim($payment['gw_allpay6_account']); //$c_order = $order['order_sn']; $c_order = $order['log_id']; $c_name = trim($order['consignee']); $c_address = trim($order['address']); $c_tel = trim($order['tel']); $c_post = trim($order['zipcode']); $c_email = trim($order['email']); $c_orderamount = $order['order_amount']; $c_ymd = date('Ymd', time()); $c_moneytype = "0"; $c_retflag = "1"; $c_returl = return_url(basename(__FILE__, '.php')); $notifytype = "0"; $c_language = $payment['gw_allpay6_language']; $c_memo1 = $order['log_id']; $c_memo2 = $order['log_id']; //$srcStr = $c_mid . $c_order . $c_orderamount . $c_ymd . $c_moneytype . $c_retflag . $c_returl . $c_paygate . $c_memo1 . $c_memo2 . $notifytype . $c_language . $c_pass; //$c_signstr = md5($srcStr); if (is_numeric($payment['gw_allpay6_installment']) && $payment['gw_allpay6_installment'] > 0) { if ($order['pay_fee'] == 0) { //判斷尚未更新過手續費 $c_orderamount = round($c_orderamount * (1 + $payment['gw_allpay6_installment'])); $pay_button = "" . $GLOBALS['_LANG']['pay_button'] . "" . $GLOBALS['_LANG']['gw_allpay6_stage'] . "期 " . $payment['gw_allpay6_installment'] * 100 . "% 利率付款 總計金額:" . $c_orderamount . "元"; $sql = 'UPDATE ' . $GLOBALS['ecs']->table('pay_log') . ' SET order_amount = ' . round($c_orderamount) . ' WHERE log_id = ' . $order['log_id']; $GLOBALS['db']->query($sql); $order_temp = array("order_amount" => $c_orderamount, "pay_fee" => round($c_orderamount) - round($order['order_amount'])); update_order($order['order_id'], $order_temp); } else { $pay_button = "" . $GLOBALS['_LANG']['pay_button'] . "" . $GLOBALS['_LANG']['gw_allpay6_stage'] . "期 " . $payment['gw_allpay6_installment'] * 100 . "% 利率付款 總計金額:" . $c_orderamount . "元"; } } else { $pay_button = "" . $GLOBALS['_LANG']['pay_button'] . "" . $GLOBALS['_LANG']['gw_allpay6_stage'] . "期零利率付款"; } $def_url = '<br /><form style="text-align:center;" method=post action="https://credit.allpay.com.tw/form_Sc_to5_fn.php">'; $def_url .= "<input type='hidden' name='client' value='" . $c_mid . "'>"; $def_url .= "<input type='hidden' name='act' value='auth'>"; $def_url .= "<input type='hidden' name='stage' value='" . $GLOBALS['_LANG']['gw_allpay6_stage'] . "'>"; $def_url .= "<input type='hidden' name='od_sob' value='" . $c_order . "'>"; $def_url .= "<input type='hidden' name='名稱' value='" . $c_name . "'>"; $def_url .= "<input type='hidden' name='地址' value='" . $c_address . "'>"; $def_url .= "<input type='hidden' name='電話' value='" . $c_tel . "'>"; $def_url .= "<input type='hidden' name='email' value='" . $c_email . "'>"; $def_url .= "<input type='hidden' name='amount' value='" . $c_orderamount . "'>"; $def_url .= "<input type='hidden' name='時間' value='" . $c_ymd . "'>"; $def_url .= "<input type='hidden' name='roturl' value='" . $c_returl . "'>"; $temp = order_goods($order['order_id']); //判斷是否使用電子發票 if ($payment['gw_ecpay3_inv_active'] == "1") { $def_url .= "<input type='hidden' name='inv_active' value='1'>"; $def_url .= "<input type='hidden' name='inv_mer_id' value='" . $payment['gw_allpay6_inv_mer_id'] . "'>"; $def_url .= "<input type='hidden' name='inv_semail' value='" . $c_email . "'>"; for ($i = 0; $i < count($temp); $i++) { $def_url .= "<input type='hidden' name='prd_name[]' value='" . $temp[$i]['goods_name'] . "'>"; $def_url .= "<input type='hidden' name='prd_qry[]' value='" . intval($temp[$i]['goods_number']) . "'>"; $def_url .= "<input type='hidden' name='prd_price[]' value='" . intval($temp[$i]['goods_price']) . "'>"; } $def_url .= "<input type='hidden' name='prd_name[]' value=運費>"; $def_url .= "<input type='hidden' name='prd_qry[]' value=1>"; $def_url .= "<input type='hidden' name='prd_price[]' value='" . intval($order['shipping_fee']) . "'>"; $def_url .= "<input type='hidden' name='prd_name[]' value=手續費>"; $def_url .= "<input type='hidden' name='prd_qry[]' value=1>"; } if ($order['pay_fee'] == 0) { $def_url .= "<input type='hidden' name='prd_price[]' value='" . $order_temp['pay_fee'] . "'>"; } else { $def_url .= "<input type='hidden' name='prd_price[]' value='" . $order['pay_fee'] . "'>"; } $def_url .= "<input type='submit' value='" . $pay_button . "'>"; $def_url .= "</form><br />"; return $def_url; }
/** * 取消一个用户订单 * * @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()); } }
* @file express.php ***/ require_once dirname(dirname(dirname(__FILE__))) . '/app.php'; need_manager(); need_auth('order'); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $file = $_FILES['upload_express']; if ($file && strpos($file['type'], 'text') === 0 && $file['error'] == 0) { $content = file($file['tmp_name']); $result = array(); foreach ($content as $k => $v) { $value = preg_split('/[\\s,;]/', $v); $data['order_id'] = $value[0]; $data['express_no'] = $value[1]; $data['express_id'] = get_express_id($value[2]); update_order($data); unset($data); } Session::Set('notice', '数据更新成功'); } } /*** * 根据快递公司名 获取快递公司分类id 或直接返回快递公司id * @param string $val 快递公司名 或 快递公司id * @return string $order['id'] 快递公司id ***/ function get_express_id($val) { /* 快递公司id为数字,依此判断直接返回或查询 */ if (is_numeric($val)) { return $val;