ecshop后台直接下单BUG的修复

2009-12-22 17:13 来源:www.chinab4c.com 作者:admin

 /* 保存收货人信息 */
    elseif ('consignee' == $step)
    {
        /* 保存订单 */
        $order = $_POST;
    //########################################
    //在这里检索。如果是会员。如果没有保留一次地址。那么这里该保留
    //xiongbin
    //#######################################
    
  $c = 0;
  $uid = 0;
  
  if(isset($_REQUEST['order_id']) && $_REQUEST['order_id']){
   $uid = $db -> getOne("select user_id from ".$ecs->table('order_info')." where order_id = ".$_REQUEST['order_id']);
   if($uid){
    $c = $db -> getOne("select count(*) from ".$ecs->table('user_address')." where user_id = $uid");
   }
  }
  
  if($c<5){
   
   include_once(ROOT_PATH . 'includes/lib_transaction.php');
   $consignee = array(
    'address_id'    => empty($_POST['address_id']) ? 0  : intval($_POST['address_id']),
    'consignee'     => empty($_POST['consignee'])  ? '' : trim($_POST['consignee']),
    'country'       => empty($_POST['country'])    ? '' : $_POST['country'],
    'user_id'       => $uid,
    'province'      => empty($_POST['province'])   ? '' : $_POST['province'],
    'city'          => empty($_POST['city'])       ? '' : $_POST['city'],
    'district'      => empty($_POST['district'])   ? '' : $_POST['district'],
    'email'         => empty($_POST['email'])      ? '' : $_POST['email'],
    'address'       => empty($_POST['address'])    ? '' : $_POST['address'],
    'zipcode'       => empty($_POST['zipcode'])    ? '' : make_semiangle(trim($_POST['zipcode'])),
    'tel'           => empty($_POST['tel'])        ? '' : make_semiangle(trim($_POST['tel'])),
    'mobile'        => empty($_POST['mobile'])     ? '' : make_semiangle(trim($_POST['mobile'])),
    'sign_building' => empty($_POST['sign_building']) ? '' : $_POST['sign_building'],
    'best_time'     => empty($_POST['best_time'])  ? '' : $_POST['best_time'],
   );
    save_consignee($consignee, true);
   
  }
       //########################################
    //在这里检索。如果是会员。如果没有保留一次地址。那么这里该保留
    //xiongbin
    //#######################################
  $order['agency_id'] = get_agency_by_regions(array($order['country'], $order['province'], $order['city'], $order['district']));
      
   
   
  update_order($order_id, $order);


        /* 该订单所属办事处是否变化 */
        $agency_changed = $old_order['agency_id'] != $order['agency_id'];

        /* todo 记录日志 */
        $sn = $old_order['order_sn'];
        admin_log($sn, 'edit', 'order');

        if (isset($_POST['next']))
        {
            /* 下一步 */
            if (exist_real_goods($order_id))
            {
                /* 存在实体商品,去配送方式 */
                ecs_header("Location: order.php?act=" . $step_act . "&order_id=" . $order_id . "&step=shipping\n");
                exit;
            }
            else
            {
                /* 不存在实体商品,去支付方式 */
                ecs_header("Location: order.php?act=" . $step_act . "&order_id=" . $order_id . "&step=payment\n");
                exit;
            }
        }