大神看下循环问题

<?php
    include_once '../inc/jos.inc.php';
    include_once '../inc/config.inc.php';
    include_once '../inc/tool.inc.php';
    include_once '../inc/mysql.inc.php';

    $template['title']='订单同步';
    $template['css']=array('../style/public_m.css');

    $link=connect();
    if(!is_login($link)){
        skip(WEB_URL.'login.php','error','请登录!');
    }

    $date=file_get_contents('date_tag.php');
if(isset($_POST['submit'])){

    $method='360buy.order.search';

    $appParams['start_date']=$_POST['start_date'];
    $appParams['end_date']=$_POST['end_date'];
    $appParams['order_state']='WAIT_SELLER_STOCK_OUT,WAIT_GOODS_RECEIVE_CONFIRM,FINISHED_L,LOCKED';
    $appParams['page']='1';
    $appParams['page_size']='100';
    $appParams['optional_fields']='';
    $appParams['sortType']='';
    $appParams['dateType']='1';

    $result=jos($method,$appParams);
    $result=json_decode($result,true);
    $order_total=$result['order_search_response']['order_search']['order_total'];

    if($order_total==0){
        file_put_contents("date_tag.php",date("Y-m-d H:i:s",strtotime($_POST['end_date'])+1));
        skip("order_down.php","error","当前日期无数据!");
    }
    $page=ceil($order_total/100);
    $query=array();
    $query2=array();
    for($i=1,$j=1;$i<=$page;$i++){
        $appParams['page']=$i;
        $result=jos($method,$appParams);
        $result=json_decode($result,true);
        $order_list=$result['order_search_response']['order_search']['order_info_list'];

        foreach($order_list as $val){

            $query[]="insert into `order` (`modified`,`customs`,`order_id`,`vender_id`,`pay_type`,`order_total_price`,`order_seller_price`,`order_payment`,`freight_price`,`seller_discount`,`order_state`,`delivery_type`,`invoice_info`,`order_remark`,`order_start_time`,`order_type`,`order_source`,`store_order`,`customs_model`,`order_sign`) values ('{$val['modified']}','{$val['customs']}','{$val['order_id']}','{$val['vender_id']}','{$val['pay_type']}','{$val['order_total_price']}','{$val['order_seller_price']}','{$val['order_payment']}','{$val['freight_price']}','{$val['seller_discount']}','{$val['order_state']}','{$val['delivery_type']}','{$val['invoice_info']}','{$val['order_remark']}','{$val['order_start_time']}','{$val['order_type']}','{$val['order_source']}','{$val['store_order']}','{$val['customs_model']}','{$val['order_sign']}')";
            $query[]="insert into `consignee_info` (`order_id`,`fullname`,`telephone`,`mobile`,`province`,`city`,`county`,`full_address`) values ('{$val['order_id']}','{$val['consignee_info']['fullname']}','{$val['consignee_info']['telephone']}','{$val['consignee_info']['mobile']}','{$val['consignee_info']['province']}','{$val['consignee_info']['city']}','{$val['consignee_info']['county']}','{$val['consignee_info']['full_address']}')";
            //加上下边的循环$query[]数据会变少
            //foreach($val['item_info_list'] as $i){
                //$query2[]="insert into item_info_list (order_id,order_start_time,sku_id,outer_sku_id,sku_name,jd_price,gift_point,ware_id,item_total) values ('{$val['order_id']}','{$val['order_start_time']}','{$i['sku_id']}','{$i['outer_sku_id']}','{$i['sku_name']}','{$i['jd_price']}','{$i['gift_point']}','{$i['ware_id']}','{$i['item_total']}')";
            //}
        }
    }
    var_dump($query);exit;
    execute_multi($link,$query,$error);
    if($error==null){
        file_put_contents("date_tag.php",date("Y-m-d H:i:s",strtotime($_POST['end_date'])+1));
        skip("order_down.php","ok","下载成功,本次共下载:".$order_total."条记录");
    }else{
        skip("order_down.php","error","下载订单数据失败:".$error);
    }
    exit;
}
?>
<?php include_once '../inc/header.inc.php';?>
<div id="main">
    <div class="title">订单同步|已下载订单截止:<?php echo $date;?></div>
<form method="post">
    <table class="au">
        <tr>
            <td>开始时间</td>
            <td><input name="start_date" type="text" readonly="true" value="<?php echo $date;?>" /></td>
            <td>截止时间</td>
            <td><input name="end_date" type="text" readonly="true" value="<?php echo date("Y-m-d H:i:s",strtotime("+30 day $date")-1);?>"/></td>
        </tr>
    </table>
    <input style="margin-top:20px;cursor:pointer;" class="btn" type="submit" name="submit" value="开始下载" />
</form>
</div>
<?php include_once '../inc/footer.inc.php';?>
已邀请:

比尔盖茨

赞同来自:

我看了下 下面的循环。和$query应该是没关系的。

比尔盖茨

赞同来自:

上面有两个地方都给$query重新赋值了。

要回复问题请先登录注册