页首Html代码

垃圾判断

<?php

    require dirname(__FILE__).'/../includes/common.inc.php';
    $_html = array();
    $_clean['version'] =  '1;2;3;4;5;6;7;8;9;10;11;12;13;14';  //版本号拼接的字符串
    
    //$_clean['version'] =  '1';  //版本号拼接的字符串
    $_clean['tag'] =  1; // 0表示第一次  1表示非第一次 
    if($_clean['tag'] = 0){
        //查出下面所有
    }elseif($_clean['tag'] = 1){
    
        //截取字符串的数组。
        $arr = explode(";",$_clean['version']);
        foreach($arr as $k){
            $_html['arr'] = $k. "\n";
            //echo $_html['arr'] ;    
            //查出版本总数
            $_result1 = _query("SELECT count(version) FROM tb_version");
            $_rows1 = _fetch_array($_result1);
            $_html1 = array();
            $_html1['count'] = $_rows1['count(version)'];    
                    
                if( strlen($v) != strlen($_html1['count'])){
                    //查出表里的所有的版本号
                    $_result2 = _query("SELECT version,tableName FROM tb_version");
                    while ($_rows2 = _fetch_array($_result2)){
                    for($y=0;$y<count($_rows2); $y++){
                    $_html2 = array();
                    $_html2['version'] = $_rows2['version'];
                    $_html2['tableName'] = $_rows2['tableName'];
                    }
                  }    
              //打印出来的数组
                //echo $_html2['version'] . "\n";
                
                echo $_html['arr'] ;
                if($_html['arr'] == $_html2['version']){
                //返回空
                    $_info['state'] = 1;
                    $_info['info'] = '';
                }elseif($_html['arr'] != $_html2['version']){
                $a=array($_html['arr']);
                $a=array($_html2['version']);
                $c=array_diff($a, $b);
                    
                
                    
                    
                }
                
            }elseif( strlen($v) != strlen($_html1['count'])){
             //查出下面所有信息
         }
     }    
    }    
?>
<?php  


   
    
//        $result=explode(";",$_clean['title']);
//        for($x=0; $x<count($result); $x++) {
//        $result1=$result[$x];
//        $result2=explode(",",$result1);
//        $dyqId=$result2[0];
//        $dyaId=$result2[1];    

?>
View Code

订单支付判断   付款成功与失败

<?php
    require dirname(__FILE__).'/includes/common.inc.php';
    $_clean = array();
    $_clean['payment'] = _check($_POST['payment']);    //支付方式
    $_clean['userId'] = _check($_POST['userId']);
    $_clean['orderNumber'] = _check($_POST['orderNumber']);
    $_clean['theGoodsName'] = _check($_POST['theGoodsName']);
    $_clean['theGoodsAddress'] = _check($_POST['theGoodsAddress']);
    $_clean['theGoodsPhone'] = _check($_POST['theGoodsPhone']);
    $_clean['theGoodsCode'] = _check($_POST['theGoodsCode']);//邮政编码
    $_info = array();
    $_data = array();
    //如果用户名或订单有值
    $_now = date('y-m-d H:i:s',time());
    if ( $_clean['userId'] > 0 && $_clean['orderNumber'] != '' ) {
        $_info['state'] = 0;
        $_info['info'] = '';
        //查询订单里  返还的积分数   实付现金    实付积分
        $_sql = "SELECT returnIntegral,payMoney,payIntegral FROM tb_order WHERE orderNumber = '{$_clean['orderNumber']}' AND userid = '{$_clean['userId']}' AND state = 0";
        $_result = _query($_sql);
        $_rows = _fetch_array($_result);
        if ( !$_rows ) {  
            //如果查不出来就是没有订单    否则有订单打印出来
            $_data['state'] = 1;
            $_data['info'] = '该订单不存在!';
            
            $_info['data'] = $_data;
            echo _json($_info);
            die;
            
        } elseif ( !!$_rows ) {
        
            $_html = array();
            $_html['returnIntegral'] = $_rows['returnIntegral'];
            $_html['payMoney'] = $_rows['payMoney'];
            $_html['payIntegral'] = $_rows['payIntegral'];
            $_html = _html($_html);
            
        }
        //查出用户的E币
        $_sql9 = "SELECT cash FROM tb_user WHERE id = '{$_clean['userId']}'";
        $_result9 = _query($_sql9);
        $_rows9 = _fetch_array($_result9);
        $_html9 = array();
        $_html9['cash'] = $_rows9['cash'];
        $_html9 = _html($_html9);
        //插入数据信息 商品名   地址 电话  邮编
        $_sql5 = "UPDATE tb_order SET theGoodsName = '{$_clean['theGoodsName']}',theGoodsAddress = '{$_clean['theGoodsAddress']}',theGoodsPhone = '{$_clean['theGoodsPhone']}',theGoodsCode = '{$_clean['theGoodsCode']}',payment = '{$_clean['payment']}' WHERE orderNumber = '{$_clean['orderNumber']}' AND userid = '{$_clean['userId']}'";
        _query($_sql5);
        //查出支付总金额
        $_sql8 = "SELECT payMoney FROM tb_order WHERE orderNumber = '{$_clean['orderNumber']}' AND userid = '{$_clean['userId']}'";
        $_result8 = _query($_sql8);
        $_rows8 = _fetch_array($_result8);
        $_html8 = array();
        $_html8['payMoney'] = $_rows8['payMoney'];
        $_html8 = _html($_html8);
        
        //优品阁账号
        if ( $_clean['payment'] == 1 ) {
        
            if ( $_html8['payMoney'] < $_html9['cash'] && $_html9['cash'] > 0 ) {
        
                $_sql1 = "UPDATE tb_user SET cash = cash - '{$_html['payMoney']}',integral = integral - '{$_html['payIntegral']}' + '{$_html['returnIntegral']}' WHERE id = '{$_clean['userId']}'";
                _query($_sql1);
            
            } else {
                
                $_data['state'] = 1;
                $_data['info'] = '现金不足!';
                $_order['data'] = $_data;
                
                echo _json($_order);
                die;
            
            }
            
            if ( _affected_rows() == 1 ) {
            
                $_data['state'] = 0;
                $_data['info'] = '支付成功!';
                
                $_sql2 = "INSERT INTO tb_cashRecord VALUES (NULL,'{$_clean['userId']}',1,'{$_clean['orderNumber']}',0,'{$_html['payMoney']}','$_now','来自Android',1)";
                _query($_sql2);
                
                if ( $_html['payIntegral'] > 0 ) {
                
                    $_sql3 = "INSERT INTO tb_integralRecord VALUES (null,'{$_clean['userId']}','{$_clean['orderNumber']}',1,0,'{$_html['preferential']}','$_now','来自Android')";
                    _query($_sql3);
                    
                }
                
                if ( $_html['returnIntegral'] > 0 ) {
                
                    $_sql4 = "INSERT INTO tb_integralRecord VALUES (null,'{$_clean['userId']}','{$_clean['orderNumber']}',1,'{$_html['returnIntegral']}',0,'$_now','来自Android')";
                    _query($_sql4);
                    
                }
                
            } else {
            
                $_data['state'] = 1;
                $_data['info'] = '支付失败!';
                
            }
            
        } elseif ( $_clean['payment'] == 4 ) {
            
            $_data['state'] = 0;
            $_data['info'] = '';
            
        }
        
        $_info['data'] = $_data;
        
    } else {
    
        $_info['state'] = 1;
        $_info['info'] = '参数有误!';
        
    }
    
    echo _json($_info);
    
    _free_result($_result);
    
    _close();

?>
View Code

订单产生于支付

<?php
    require dirname(__FILE__).'/includes/common.inc.php';
    $_clean = array();
    $_clean['userId'] = _check($_POST['userId']);
    $_clean['preferential'] = _check($_POST['preferential']);
    $_clean['distribution'] = _check($_POST['distribution']);//1.快递配送 2.门店自提
    $_clean['note'] = _check($_POST['note']);
    $_clean['theGoodsName'] = _check($_POST['theGoodsName']);
    $_clean['theGoodsAddress'] = _check($_POST['theGoodsAddress']);
    $_clean['theGoodsCode'] = _check($_POST['theGoodsCode']);
    $_clean['theGoodsPhone'] = _check($_POST['theGoodsPhone']);
    $_clean['payment'] = _check($_POST['payment']);
    $_order = array();
    $_data = array();
    if ( $_clean['userId'] > 0 ) {
        $_order['state'] = 0;
        $_order['info'] = '';
                //购物车查找商品id和数目
        $_sql = "SELECT GoodsInfoId,number FROM tb_shopCart WHERE userid = '{$_clean['userId']}' AND state = 0";
        $_result = _query($_sql);
        while ( $_rows = _fetch_array($_result) ) {
            $_html = array();
            $_html['GoodsInfoId'] = $_rows['GoodsInfoId'];
            $_html['number'] = $_rows['number'];
                //商品中查找购物车中的商品详细信息
            $_sql1 = "SELECT memberPrice,returnIntegral,preferential,postagePrice FROM tb_GoodsInfo WHERE Id = '{$_html['GoodsInfoId']}'";
            $_result1 = _query($_sql1);
            $_rows1 = _fetch_array($_result1);
            $_html['memberPrice'] = $_rows1['memberPrice'];
            $_html['returnIntegral'] = $_rows1['returnIntegral'];
            $_html['preferential'] = $_rows1['preferential'];
            $_html['postagePrice'] = $_rows1['postagePrice'];
            $_html = _html($_html);
            //快递配送
            if ( $_clean['distribution'] == 1 ) {
                $_data['postagePrice'] += $_html['number'] * $_html['postagePrice']; //邮费
                $_data['memberPrice'] += $_html['memberPrice'] * $_html['number'];//会员价
                $_data['totalMoney'] += $_html['memberPrice'] * $_html['number'] + $_html['number'] * $_html['postagePrice'];//总价=总价+会员价*数量  + 数量* 邮费    
            } elseif ( $_clean['distribution'] == 2 ) {//自提
                $_data['memberPrice'] += $_html['memberPrice'] * $_html['number'];//会员价
                $_data['totalMoney'] += $_html['memberPrice'] * $_html['number'];//总价
            }
            //四舍五入
            $_data['postagePrice'] = number_format($_data['postagePrice'], 2, '.', '');
            $_data['memberPrice'] = number_format($_data['memberPrice'], 2, '.', '');
            $_data['totalMoney'] = number_format($_data['totalMoney'], 2, '.', '');
            //优惠积分       返还积分数
            $_data['preferential'] += $_html['number'] * $_html['preferential'];
            $_data['returnIntegral'] += $_html['number'] * $_html['returnIntegral'];
        }
        //积分    账户
        $_sql2 = "SELECT integral,cash FROM tb_user WHERE id = '{$_clean['userId']}'";
        $_result2 = _query($_sql2);
        $_rows2 = _fetch_array($_result2);
        $_html2 = array();
        $_html2['integral'] = $_rows2['integral'];
        $_html2['cash'] = $_rows2['cash'];
        $_html2 = _html($_html2);
        $_now = date('Y-m-d H:i:s',time());
         //如果优惠积分总积分  大于商品的总积分
        if ( $_data['preferential'] > $_html2['integral'] ) {
            $_preferential = $_html2['integral'];//查出来的积分
            
        } elseif ( $_data['preferential'] <= $_html2['integral'] ) {
            $_preferential = $_data['preferential'];//商品后总积分
            }
        //如果传过来的积分大于
        if( $_clean['preferential'] > $_preferential ) {
            $_data['state'] = 1;
            $_data['info'] = '您所传的积分超出最大使用量或者账户总量!';
            
            $_order['data'] = $_data;
            echo _json($_order);
            die;
        } else {
            //总价格
            $_data['totalMoney'] = $_data['totalMoney'] - $_clean['preferential'] / 10;
            
            if ( $_clean['payment'] == 1 ) {
                //如果账户金额够
                if ( $_data['totalMoney'] < $_html2['cash'] && $_html2['cash'] > 0 ) {
            
                    $year_code = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
                    $_data['orderNumber'] = $year_code[intval(date('Y'))-2014].strtoupper(dechex(date('m'))).date('d').substr(time(),-5).substr(microtime(),2,5).sprintf('d',rand(0,99));//生成订单号
                    //生成订单
                    $_sql3 = "INSERT INTO tb_order VALUES (NULL,'$_now','{$_data['orderNumber']}','{$_clean['userId']}','{$_clean['theGoodsName']}','{$_clean['theGoodsAddress']}','{$_clean['theGoodsCode']}','{$_clean['theGoodsPhone']}','{$_clean['distribution']}','{$_data['returnIntegral']}','{$_clean['payment']}','{$_data['totalMoney']}','{$_clean['preferential']}',0,'{$_clean['note']}')";
                    _query($_sql3);
                    
                } else {
                
                    $_data['state'] = 1;
                    $_data['info'] = '现金不足!';
                    $_order['data'] = $_data;
                    
                    echo _json($_order);
                    die;
                
                }
                //否则支付宝支付
            } elseif ( $_clean['payment'] == 4 ) {
            //提交订单
                $year_code = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
                $_data['orderNumber'] = $year_code[intval(date('Y'))-2014].strtoupper(dechex(date('m'))).date('d').substr(time(),-5).substr(microtime(),2,5).sprintf('d',rand(0,99));//生成订单号
                
                $_sql3 = "INSERT INTO tb_order VALUES (NULL,'$_now','{$_data['orderNumber']}','{$_clean['userId']}','{$_clean['theGoodsName']}','{$_clean['theGoodsAddress']}','{$_clean['theGoodsCode']}','{$_clean['theGoodsPhone']}','{$_clean['distribution']}','{$_data['returnIntegral']}','{$_clean['payment']}','{$_data['totalMoney']}','{$_clean['preferential']}',0,'{$_clean['note']}')";
                _query($_sql3);
            }
            if ( _affected_rows() == 1 ) {
                $_data['state'] = 0;
                $_data['info'] = '订单提交成功!';
                //在购物车中查找商品id  数量
                $_sql5 = "SELECT GoodsInfoId,number FROM tb_shopCart WHERE state = 0 AND userid = '{$_clean['userId']}'";
                $_result5 = _query($_sql5);
                while ( $_rows5 = _fetch_array($_result5) ) {
                    $_html5 = array();
                    $_html5['GoodsInfoId'] = $_rows5['GoodsInfoId'];
                    $_html5['number'] = $_rows5['number'];
                    $_html5 = _html($_html5);
                    
                    //查找商品所有价格信息
                    $_sql6 = "SELECT GoodsName,memberPrice,returnIntegral,preferential,postagePrice FROM tb_GoodsInfo WHERE id = '{$_html5['GoodsInfoId']}'";
                    $_result6 = _query($_sql6);
                    $_rows6 = _fetch_array($_result6);
                    $_html6 = array();
                    $_html6['title'] = $_rows6['GoodsName'];
                    $_html6['memberPrice'] = $_rows6['memberPrice'];
                    $_html6['returnIntegral'] = $_rows6['returnIntegral'];
                    $_html6['preferential'] = $_rows6['preferential'];
                    $_html6['postagePrice'] = $_rows6['postagePrice'];
                    $_html6 = _html($_html6);
                    //插入订单订单商品表
                    $_sql7 = "INSERT INTO tb_orderGoods VALUES (NULL,'$_now','{$_data['orderNumber']}','{$_html5['GoodsInfoId']}','{$_html6['memberPrice']}','{$_html6['returnIntegral']}','{$_html6['preferential']}','{$_html6['postagePrice']}','{$_html5['number']}')";
                    _query($_sql7);
                }
                //更新购物车状态
                $_sql4 = "UPDATE tb_shopCart SET state = 1 WHERE userid = '{$_clean['userId']}'";
                _query($_sql4);
                
                $_data['payment'] = $_clean['payment'];
                $_data['title'] .= $_html6['title'];
                
            } else {
                $_data['state'] = 1;
                $_data['info'] = '订单提交失败!';
            }
        }
        $_order['data'] = $_data;
    } else {
        $_order['state'] = 1;
        $_order['info'] = '参数有误!';
    }
    
    echo _json($_order);
    
    _free_result($_result);
    _free_result($_result1);
    _free_result($_result2);
    
    _close();

?>
View Code
<?php
    require dirname(__FILE__).'/includes/common.inc.php';
    $_now = date('Y-m-d H:i:s',time());
    $_clean = array();
    $_clean['userId'] = _check($_POST['userId']);
    $_clean['orderNumber'] = _check($_POST['orderNumber']);
    $_clean['deliveryName'] = _check($_POST['deliveryName']);
    $_clean['deliveryAddress'] = _check($_POST['deliveryAddress']);
    $_clean['deliveryPhone'] = _check($_POST['deliveryPhone']);
    $_clean['deliveryCode'] = _check($_POST['deliveryCode']);
    $_clean['orderPayWay'] = _check($_POST['orderPayWay']);
    $_orderDetail = array();
    $_data = array();
    //订单号   支付方式   用户ID
    if ( $_clean['orderNumber'] != '' && $_clean['orderPayWay'] != '' && $_clean['userId'] != '' ) {
        $_orderDetail['state'] = 0;
        $_orderDetail['info'] = '';
        //更新数据
        _query("UPDATE tb_easyGoodsOrder SET deliveryName = '{$_clean['deliveryName']}',deliveryAddress = '{$_clean['deliveryAddress']}',deliveryPhone = '{$_clean['deliveryPhone']}',deliveryCode = '{$_clean['deliveryCode']}' WHERE orderNumber = '{$_clean['orderNumber']}'");
        //查询出订单信息
        $_sql2 = "SELECT goodsModule,orderPayMoney,orderPayIntegral,integralPayState FROM tb_easyGoodsOrder WHERE userid = '{$_clean['userId']}' AND orderNumber = '{$_clean['orderNumber']}' AND orderStatus = 0";
        $_result2 = _query($_sql2);
        $_rows2 = _fetch_array($_result2);
        
        if ( !$_rows2 ) {
            _free_result($_result2);
            $_data['state'] = 1;
            $_data['info'] = '该订单不存在!';
            $_orderDetail['data'] = $_data;
            echo _json($_orderDetail);
            die;
        } else {
            $_html2 = array();
            if ( $_rows2['goodsModule'] == 1 ) {
                $_html2['goodsModule'] = "秒杀商品支付";
            } elseif ( $_rows2['goodsModule'] == 2 ) {
                $_html2['goodsModule'] = "兑换商品支付";
            } elseif ( $_rows2['goodsModule'] == 3 ) {
                $_html2['goodsModule'] = "特惠购物支付";
            } elseif ( $_rows2['goodsModule'] == 4 ) {
                $_html2['goodsModule'] = "广告商品领取";
            } elseif ( $_rows2['goodsModule'] == 5 ) {
                $_html2['goodsModule'] = "抽奖商品领取";
            }
            $_html2['orderPayMoney'] = $_rows2['orderPayMoney'];
            $_html2['orderPayIntegral'] = $_rows2['orderPayIntegral'];
            $_html2['integralPayState'] = $_rows2['integralPayState'];
            $_html2 = _html($_html2);
            
            $_sql3 = "SELECT integral_easyhunt,cash_easyhunt FROM tb_user WHERE id = '{$_clean['userId']}'";
            $_result3 = _query($_sql3);
            $_rows3 = _fetch_array($_result3);
            $_html3 = array();
            $_html3['integral_easyhunt'] = $_rows3['integral_easyhunt'];
            $_html3['cash_easyhunt'] = $_rows3['cash_easyhunt'];
            $_html3 = _html($_html3);
            //如果是预存款
            if ( $_clean['orderPayWay'] == '预存款' ) {
                    //如果订单要支付的易币  订单是未付款
                if ( $_html2['orderPayIntegral'] > 0 && $_html2['integralPayState'] == 0 ) {
                    //如果账户易币小于要支付的易币   易币不足
                    if ( $_html3['integral_easyhunt'] < $_html2['orderPayIntegral'] ) {
                        $_data['state'] = 2;
                        $_data['info'] = '易币不足!';
                        
                        $_orderDetail['data'] = $_data;
                        echo _json($_orderDetail);
                        die;
                        //否则账户小于要支付的账户   存款不足
                    } elseif ( $_html3['cash_easyhunt'] < $_html2['orderPayMoney'] ) {
                        $_data['state'] = 3;
                        $_data['info'] = '预存款不足!';
                        
                        $_orderDetail['data'] = $_data;
                        echo _json($_orderDetail);
                        die;
                    } else {
                        mysql_query("BEGIN");
                        $flag=0;
                        //用户账户变动
                        _query("UPDATE tb_user SET cash_easyhunt = cash_easyhunt - '{$_html2['orderPayMoney']}',integral_easyhunt = integral_easyhunt - '{$_html2['orderPayIntegral']}' WHERE id = '{$_clean['userId']}'");
                        // 易币账户记录
                        _query("INSERT INTO tb_cashAndebLog VALUES (null,1,'{$_clean['userId']}','$_now','来自Android','{$_html2['goodsModule']}','{$_html2['orderPayIntegral']}',0)");
                        //现金记录
                        _query("INSERT INTO tb_cashAndebLog VALUES (null,2,'{$_clean['userId']}','$_now','来自Android','{$_html2['goodsModule']}','{$_html2['orderPayMoney']}',0)");
                        // 支付状态 易币支付状态   支付状态  订单状态和
                        _query("UPDATE tb_easyGoodsOrder SET integralPayState = 1,orderPayWay = '预存款支付' orderStatus = 1 WHERE orderNumber = '{$_clean['orderNumber']}'");
                        
                        $flag=1;
                        if($flag==1){
                            mysql_query("COMMIT");
                            $_data['state'] = 0;
                            $_data['info'] = '支付成功';
                        }else{
                            mysql_query("ROLLBACK");
                            $_data['state'] = 4;
                            $_data['info'] = '支付失败';
                        }
                    }
                } else {
                    //如果存款不足
                    if ( $_html3['cash_easyhunt'] < $_html2['orderPayMoney'] ) {
                        $_data['state'] = 3;
                        $_data['info'] = '预存款不足!';
                        
                        $_orderDetail['data'] = $_data;
                        echo _json($_orderDetail);
                        die;
                    } else {
                        mysql_query("BEGIN");
                        $flag=0;
                        ////用户账户变动
                        _query("UPDATE tb_user SET cash_easyhunt = cash_easyhunt - '{$_html2['orderPayMoney']}' WHERE id = '{$_clean['userId']}'");
                        // 易币账户记录
                        _query("INSERT INTO tb_cashAndebLog VALUES (null,2,'{$_clean['userId']}','$_now','来自Android','{$_html2['goodsModule']}','{$_html2['orderPayMoney']}',0)");
                            //  态   订单状态和
                        _query("UPDATE tb_easyGoodsOrder SET orderPayWay = '预存款支付',orderStatus = 1 WHERE orderNumber = '{$_clean['orderNumber']}'");
                        
                        $flag=1;
                        if($flag==1){
                            mysql_query("COMMIT");
                            $_data['state'] = 0;
                            $_data['info'] = '支付成功';
                        }else{
                            mysql_query("ROLLBACK");
                            $_data['state'] = 4;
                            $_data['info'] = '支付失败';
                        }
                    }
                }
            } elseif ( $_clean['orderPayWay'] == '支付宝' ) {
                
            }
        }
        
        $_orderDetail['data'] = $_data;
        
    } else {
        $_orderDetail['state'] = 1;
        $_orderDetail['info'] = '参数有误!';
    }
    
    echo _json($_orderDetail);
    
    _close();
    
?>
View Code

判断以验证未验证在验证

<?php

    require dirname(__FILE__).'/../includes/common.inc.php';
    $_clean = array();
    $_clean['userId'] = _check($_POST['userId']);
    $_clean['adInfoId'] = _check($_POST['adInfoId']);
    $_now = date('Y-m-d H:i:s',time());
    $_info = array();
    $_data = array();
    if ( $_clean['userId'] > 0 && $_clean['adInfoId'] > 0 ) {
        $_info['state'] = 0;
        $_info['info'] = '';
        $_sql = "SELECT * FROM tb_adInfo WHERE id = '{$_clean['adInfoId']}'";
        $_result = _query($_sql);
        $_rows = _fetch_array($_result);
        $_sql1 = "SELECT * FROM tb_adInfoLog WHERE id = (SELECT id FROM tb_adInfoLog WHERE adInfoId = '{$_clean['adInfoId']}' AND userid = '{$_clean['userId']}' ORDER BY id DESC LIMIT 1) AND DATEDIFF(NOW(),addDates) < '{$_rows['interval']}'";
        $_result1 = _query($_sql1);
        $_row1 = _num_rows($_result1);
        if ( $_row1 > 0 ) {
            $_data['state'] = 1;
            $_data['info'] = '已验证!';
        } else {
            $_sql2 = "SELECT advertisingType,rewardType,goodsId,totalReward,oneReward FROM tb_adInfo WHERE id = '{$_clean['adInfoId']}' AND State=1";
            $_result2 = _query($_sql2);
            $_rows2 = _fetch_array($_result2);
            $_html2 = array();
            $_html2['advertisingType'] = $_rows2['advertisingType'];
            $_html2['rewardType'] = $_rows2['rewardType'];
            $_html2['goodsId'] = $_rows2['goodsId'];
            $_html2['totalReward'] = $_rows2['totalReward'];
            $_html2['oneReward'] = $_rows2['oneReward'];
            $_html2 = _html($_html2);
            
            if($_html2['advertisingType']==1){
                $operation="广告浏览";
            }elseif($_html2['advertisingType']==2){
                $operation="促销活动";
            }elseif($_html2['advertisingType']==3){
                $operation="商家宣传";
            }
            
            mysql_query("BEGIN");
            $flag=0;
            
            //添加浏览记录
            _query("insert into tb_adInfoLog values(null,'{$_clean['userId']}','{$_clean['adInfoId']}',now(),'来自Android')");
            if( $_html2['totalReward'] / $_html2['oneReward'] >= 1 ) {
                
                if ( $_html2['rewardType'] == 1 ) {
                    //给会员添加易币奖励
                    _query("update tb_user set integral_easyhunt = integral_easyhunt + '{$_html2['oneReward']}' where id = '{$_clean['userId']}'");
                    //添加易币增加的变动记录
                    _query("insert into tb_cashAndebLog values(null,1,'{$_clean['userId']}',now(),'来自Android','$operation','{$_html2['oneReward']}',1)");
                } elseif ( $_html2['rewardType'] == 2 ) {
                    //给会员添加现金
                    _query("update tb_user set cash_easyhunt = cash_easyhunt + '{$_html2['oneReward']}' where id = '{$_clean['userId']}'");
                    //添加现金增加的变动记录
                    _query("insert into tb_cashAndebLog values(null,2,'{$_clean['userId']}',now(),'来自Android','$operation','{$_html2['oneReward']}',1)");
                } elseif ( $_html2['rewardType'] == 3 ) {
                    //实物奖励,查询出奖励的实物,添加实物订单
                    $_result3 = _query("select * from tb_goods where goodsId = '{$_html2['goodsId']}'");
                    $_rows3 = _fetch_array($_result3);
                    $_html3 = array();
                    $_html3['company'] = $_rows3["company"];
                    $_html3['goodsMoneyPrice'] = $_rows3["goodsMoneyPrice"];
                    $_html3['goodsIntegralPrice'] = $_rows3["goodsIntegralPrice"];
                    $_html3['goodsPostage'] = $_rows3["goodsPostage"];
                    
                    //添加广告区订单(点击赚和来就赚)
                    $year_code = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
                    $_orderNumber = $year_code[intval(date('Y'))-2014].strtoupper(dechex(date('m'))).date('d').substr(time(),-5).substr(microtime(),2,5).sprintf('d',rand(0,99));
                    
                    if( $_html3['goodsMoneyPrice'] > 0 or $_html3['goodsIntegralPrice'] > 0 or $_html3['goodsPostage'] > 0 ){
                        _query("insert into tb_easyGoodsOrder values(null,4,now(),'来自Android','{$_html3['company']}','{$_clean['userId']}','$_orderNumber','{$_html2['goodsId']}','{$_html3['goodsMoneyPrice']}','{$_html3['goodsIntegralPrice']}','{$_html3['goodsPostage']}',1,'浏览广告奖励',0,0,0,'浏览广告',0,'','','','','','')");
                    }else{
                        _query("insert into tb_goodsOrder values(null,4,now(),'来自Android','{$_html3['company']}','{$_clean['userId']}','$_orderNumber','{$_html2['goodsId']}',0,0,0,1,'浏览广告奖励',0,0,1,'浏览广告',1,'','','','','','')");
                    }
                    
                }
            }else{
                $_data['state'] = 1;
                $_data['info'] = '奖励已经发放完了';
            }
            
            $flag=1;
            if($flag==1){
                mysql_query("COMMIT");
                $_data["state"] = 0;
                $_data['info'] = '验证成功';
            }else{
                mysql_query("ROLLBACK");
                $_data["state"] = 1;
                $_data['info'] = '验证失败';
            }
        }
        
        $_info['data'] = $_data;
    
    } else {
    
        $_info['state'] = 1;
        $_info['info'] = '参数有误!';
    
    }
    
    echo _json($_info);
    
    _free_result($_result);
    _free_result($_result1);
    _free_result($_result2);
    _free_result($_result3);
    
    _close();

?>
View Code

判断抽奖一抽未抽   支付等

<?php

    require dirname(__FILE__).'/../includes/common.inc.php';
    $_clean = array();
    $_clean['userId'] = _check($_POST['userId']);
    $_clean['prizeId'] = _check($_POST['prizeId']);
    
    $_info = array();
    $_data = array();
    if ( $_clean['userId'] > 0 && $_clean['prizeId'] > 0 ) {
        $_info['state'] = 0;
        $_info['info'] = '';
        $_sql = "SELECT id FROM tb_thePrize WHERE id = '{$_clean['prizeId']}' AND totalReward > 0 AND State = 1";
        $_result = _query($_sql);
        $_row = _num_rows($_result);
        if ( $_row == 0 ) {
            $_data['state'] = 1;
            $_data['info'] = '该奖品不存在或已撤销';
            
            $_info['data'] = $_data;
            echo _json($_info);
            die;
        } else {
            $_sql1 = "SELECT * FROM tb_thePrizeLog WHERE userid = '{$_clean['userId']}' AND thePrizeId = '{$_clean['prizeId']}' AND category = 1 AND to_days(now()) = to_days(addTimes)";
            $_result1 = _query($_sql1);
            $_row1 = _num_rows($_result1);
            if ( $_row1 == 0 ) {
            
                $_data['state'] = 2;
                $_data['info'] = '今日已抽取过该奖品';
                
                $_info['data'] = $_data;
                echo _json($_info);
                die;
            } else {
                $_sql2 = "SELECT * FROM tb_thePrize WHERE id = '{$_clean['prizeId']}' AND State = 1";
                $_result2 = _query($_sql2);
                $_rows2 = _fetch_array($_result2);
                $_html2 = array();
                $_html2['company'] = $_rows2['company'];
                $_html2['useIntegral'] = $_rows2['useIntegral'];
                $_html2['adInfoUrl'] = $_rows2['adInfoUrl'];
                $_html2['thePrizeChangeOf'] = $_rows2['thePrizeChangeOf'];
                $_html2['thePrizeType'] = $_rows2['thePrizeType'];
                $_html2 = _html($_html2);
                if ( $_html2['company'] == 0 ) {
                    $_sql3 = "SELECT integral_easyhunt FROM tb_user WHERE id = '{$_clean['userId']}'";
                    $_result3 = _query($_sql3);
                    $_rows3 = _fetch_array($_result3);
                    if ( $_rows3['integral_easyhunt'] < $_html2['useIntegral'] ) {
                    
                        $_data['state'] = 3;
                        $_data['info'] = '易币不足!';
                        
                        $_info['data'] = $_data;
                        echo _json($_info);
                        die;
                    } else {
                        $_v1 = $_html2['thePrizeChangeOf'];
                        $_v2 = 100 - $_html2['thePrizeChangeOf'];
                        $prize_arr = array( 
                            '0' => array('id'=>1,'min'=>array(1,302,242,182,122,62),'max'=>array(29,328,268,208,148,88),'prize'=>'中奖','v'=>$_v1), 
                            '1' => array('id'=>2,'min'=>array(32,92,152,212,272,332), 'max'=>array(58,118,178,238,298,358),'prize'=>'谢谢参与','v'=>$_v2)
                        ); 
                        
                        function getRand($proArr) { 
                            $result = ''; //概率数组的总概率精度 
                            $proSum = array_sum($proArr);  
                            //概率数组循环 
                            foreach ($proArr as $key => $proCur) { 
                                $randNum = mt_rand(1, $proSum); 
                                if ($randNum <= $proCur) { 
                                    $result = $key; 
                                    break; 
                                } else { 
                                    $proSum -= $proCur; 
                                } 
                            } 
                            unset ($proArr);  
                            return $result; 
                        }
                        
                        foreach ( $prize_arr as $key => $val ) { 
                            $arr[$val['id']] = $val['v']; 
                        } 
                        
                        $rid = getRand($arr); //根据概率获取奖项id 
                        $res = $prize_arr[$rid-1]; //中奖项 
                        $min = $res['min']; 
                        $max = $res['max']; 
                        
                        if ( $res['id'] == 2 ) { 
                            _query("UPDATE tb_user SET integral_easyhunt = integral_easyhunt - '{$_html2['useIntegral']}' WHERE id = '{$_clean['userId']}'");
                            //添加易币变动记录(减少记录)
                            _query("INSERT INTO tb_cashAndebLog VALUES (null,1,'{$_clean['userId']}',now(),'来自Android','在线抽奖','{$_html2['useIntegral']}',0)");
                            //添加奖品抽奖记录
                            _query("INSERT INTO tb_thePrizeLog VALUES (null,'{$_clean['userId']}',now(),'来自Android','{$_clean['prizeId']}',1)");
                            
                            $i = mt_rand(0,5); 
                            $_data['angle'] = mt_rand($min[$i],$max[$i]); 
                            $_data['info'] = '未中奖'; //标示未中奖
                        }else{ 
                            $i = mt_rand(0,5);
                            //$_data['angle'] = mt_rand($min[$i],$max[$i]); //随机生成一个角度
                            $_data['type'] = $_html2['thePrizeType']; 
                            $_data['state'] = 0;
                            $_data['info'] = '中奖'; //标示中奖
                        }
                        $_data["user"] = $_clean['userId'];
                        $_data["state1"] = "抽奖成功";
                    }
                } elseif ( $_html2['company'] > 0 ) {
                    $_sql4 = "SELECT * FROM tb_adInfoLog WHERE userid = '{$_clean['userId']}' AND adInfoId IN (SELECT id FROM tb_adInfo WHERE company = '{$_html2['company']}') AND to_days(now()) = to_days(addDates)";
                    $_result4 = _query($_sql4);
                    $_rows4 = _fetch_array($_result4);
                    
                    if ( $_rows4 == 0 ) {
                        $_data['state'] = 4;
                        $_data['info'] = '未阅读广告';
                        $_data['url'] = $_html2['adInfoUrl'];
                        
                        $_info['data'] = $_data;
                        echo _json($_info);
                        die;
                    } else {
                        $_v1 = $_html2['thePrizeChangeOf'];//奖品的中奖几率
                        $_v2 = 100 - $_html2['thePrizeChangeOf'];//谢谢参与的几率
                        $prize_arr = array( 
                            '0' => array('id'=>1,'min'=>array(1,302,242,182,122,62),'max'=>array(29,328,268,208,148,88),'prize'=>'中奖','v'=>$_v1), 
                            '1' => array('id'=>2,'min'=>array(32,92,152,212,272,332), 'max'=>array(58,118,178,238,298,358),'prize'=>'谢谢参与','v'=>$_v2) 
                        ); 
                        
                        function getRand($proArr) { 
                            $result = ''; 
                            //概率数组的总概率精度 
                            $proSum = array_sum($proArr);  
                            //概率数组循环 
                            foreach ($proArr as $key => $proCur) { 
                                $randNum = mt_rand(1, $proSum); 
                                if ($randNum <= $proCur) { 
                                    $result = $key; 
                                    break; 
                                } else { 
                                    $proSum -= $proCur; 
                                } 
                            } 
                            unset ($proArr);  
                            return $result; 
                        }
                        
                        foreach ($prize_arr as $key => $val) { 
                        $arr[$val['id']] = $val['v']; 
                        } 
                        $rid = getRand($arr); //根据概率获取奖项id 
                        $res = $prize_arr[$rid-1]; //中奖项 
                        $min = $res['min']; 
                        $max = $res['max'];
                        
                        if ( $res['id'] == 2 ) { //谢谢参与 
                            $i = mt_rand(0,5); 
                            $_data['angle'] = mt_rand($min[$i],$max[$i]); 
                            $_data['info'] = '未中奖'; 
                            //添加奖品抽奖记录
                            _query("INSERT INTO tb_thePrizeLog VALUES (null,'{$_clean['userId']}',now(),'来自Android','{$_clean['prizeId']}',1)");
                        }else{ 
                            $i = mt_rand(0,5);
                            //$_data['angle'] = mt_rand($min[$i],$max[$i]); //随机生成一个角度
                            $_data['state'] = 0; 
                            $_data['type'] = $_html2['thePrizeType'];
                            $_data['info'] = '中奖'; 
                        }
                        $_data["user"] = $_clean['userId'];
                        $_data["state1"] = "抽奖成功";
                    }
                }
            }
        }
        $_info['data'] = $_data;
    } else {
        $_info['state'] = 1;
        $_info['info'] = '参数有误!';
    }
    
    echo _json($_info);
    
    _close();

?>
View Code

秒杀  未秒杀  已秒杀 开始秒杀

<?php

    require dirname(__FILE__).'/../includes/common.inc.php';

    $_clean = array();
    $_clean['userId'] = _check($_POST['userId']);
    $_clean['goodsId'] = _check($_POST['goodsId']);

    $_order = array();
    
    $_data = array();
    
    $_now = date('Y-m-d H:i:s',time());
    $_now_ymd = date('Y-m-d',time());
    $_now_hms = date('H:i:s',time());

    $_ymd = explode("-",$_now_ymd);
    $_ymd_y = $_ymd[0];
    $_ymd_m = $_ymd[1];
    $_ymd_d = $_ymd[2];
    $_ymd = $_ymd_y.$_ymd_m.$_ymd_d;

    $_hms = explode(":",$_now_hms);
    $_hms_h = $_hms[0];
    $_hms_m = $_hms[1];
    $_hms_s = $_hms[2];
    $_hms_m1 = $_hms[1] + 45;
    if( $_hms_m1 >= 60 ){
        $_hms_m1 = $_hms_m1 - 60;
        $_hms_h1 = $_hms[0] + 1;

        $_now1 = $_now_ymd . ' ' . $_hms_h1 . ':' . $_hms_m1 . ':' . $_hms_s;  //有效期
    }else{
        $_now1 = $_now_ymd . ' ' . $_hms_h . ':' . $_hms_m1 . ':' . $_hms_s;
    }

    $_hms = $_hms_h.$_hms_m.$_hms_s;
    
    $year_code = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
    $_data['orderNumber'] = $year_code[intval(date('Y'))-2014].strtoupper(dechex(date('m'))).date('d').substr(time(),-5).substr(microtime(),2,5).sprintf('d',rand(0,99));//生成订单号

    $_orderBuyCount = 1;//数量为1
    
    if ( $_clean['userId'] != '' && $_clean['goodsId'] != '' ) {
        $_order['state'] = 0;
        $_order['info'] = '';
        
        $_sql = "SELECT companyId,goodsName,goodsType,goodsMoneyPrice,goodsPicture,goodsIntegralPrice,goodsPostage,goodsInventory FROM tb_goods WHERE goodsId = '{$_clean['goodsId']}' AND goodsShow = 1 LIMIT 1";
        $_result = _query($_sql);
        $_rows = _fetch_array($_result);
        $_html = array();
        $_html['companyId'] = $_rows['companyId'];
        $_html['title'] = $_rows['goodsName'];
        $_html['goodsType'] = $_rows['goodsType'];
        $_html['goodsMoneyPrice'] = $_rows['goodsMoneyPrice'];
        $_html['pic'] = $_rows['goodsPicture'];
        $_html['goodsIntegralPrice'] = $_rows['goodsIntegralPrice'];
        $_html['goodsPostage'] = $_rows['goodsPostage'];
        $_html['goodsInventory'] = $_rows['goodsInventory'];
        $_html = _html($_html);
        
        $_sql2 = "SELECT province,theCity,county,address,phone,realName FROM tb_user WHERE id = '{$_clean['userId']}'";
        $_result2 = _query($_sql2);
        $_rows2 = _fetch_array($_result2);
        $_html2 = array();
        $_html2['province'] = $_rows['province'];
        $_html2['theCity'] = $_rows['theCity'];
        $_html2['county'] = $_rows['county'];
        $_html2['address'] = $_rows['address'];
        $_html2['phone'] = $_rows['phone'];
        $_html2['realName'] = $_rows['realName'];
        $_html2 = _html($_html2);
        
        $_data['realName'] = $_html2['realName'];
        $_data['address'] = $_html2['province'].$_html2['theCity'].$_html2['county'].$_html2['address'];
        $_data['phone'] = $_html2['phone'];
        
        if ( $_now_hms >= '12:00:00' && $_now_hms <= '13:00:00' ) {
            if ( $_html['goodsInventory'] >= $_orderBuyCount ) {
                $_sql1 = "INSERT INTO tb_goodsOrder (
                                                    companyId,
                                                    goodsType,
                                                    orderDate,
                                                    orderIP,
                                                    orderNumber,
                                                    userId,
                                                    goodsId,
                                                    goodsName,
                                                    goodsPicture,
                                                    goodsMoneyPrice,
                                                    goodsIntegralPrice,
                                                    goodsPostage,
                                                    orderBuyCount,
                                                    orderNote,
                                                    orderPayMoney,
                                                    orderPayIntegral,
                                                    orderPayWay,
                                                    orderStatus,
                                                    orderEffectiveDate,
                                                    deliveryName,
                                                    deliveryAddress,
                                                    deliveryPhone,
                                                    deliveryCode,
                                                    courierCompany,
                                                    courierOrderNo
                                                    ) 
                                             VALUES (
                                                    '{$_html['companyId']}',
                                                    '{$_html['goodsType']}',
                                                    '$_now',
                                                    '来自Android',
                                                    '{$_data['orderNumber']}',
                                                    '{$_clean['userId']}',
                                                    '{$_clean['goodsId']}',
                                                    '{$_html['title']}',
                                                    '{$_html['pic']}',
                                                    '{$_html['goodsMoneyPrice']}',
                                                    '{$_html['goodsIntegralPrice']}',
                                                    '{$_html['goodsPostage']}',
                                                    1,
                                                    '',
                                                    '',
                                                    '',
                                                    '',
                                                    0,
                                                    '$_now1',
                                                    '{$_data['realName']}',
                                                    '{$_data['address']}',
                                                    '{$_data['phone']}',
                                                    '',
                                                    '',
                                                    ''
                                                    )";
                _query($_sql1);
        
                if( _affected_rows() == 1 ){
                    $_data['state'] = 0;
                    $_data['info'] = '订单提交成功!';
                }else{
                    $_data['state'] = 2;
                    $_data['info'] = '订单提交失败!';
                }
            } else {
                $_data['state'] = 2;
                $_data['info'] = '库存不足!';
                
                $_order['data'] = $_data;
                echo _json($_order);
                die;
            }
        } else {
            $_data['state'] = 1;
            $_data['info'] = '秒杀时间已过或者秒杀未开始';
            
            $_order['data'] = $_data;
            echo _json($_order);
            die;
        } 
    } else {
        $_order['state'] = 1;
        $_order['info'] = '参数有误!';
    }

    $_order['data'] = $_data;

    echo _json($_order);

    _free_result($_result);
    
    _close();

?>
View Code

 砸奖  查出砸奖信息  和中奖信息

<?php

    require dirname(__FILE__).'/../includes/common.inc.php';
    
    $_clean = array();
    $_clean['model'] = _check($_POST['model']);
    $_clean['cityId'] = _check($_POST['cityId']);
    
    $_info = array();
    $_data = array();
    
    if ( $_clean['model'] != '' ) {
        $_info['state'] = 0;
        $_info['info'] = '';
        //查出当前数据信息
        $_sql = "SELECT * FROM tb_easySmashingInfo WHERE model = '{$_clean['model']}' AND state = 1";
        $_result = _query($_sql);
        $_rows = _fetch_array($_result);
        $_now = array();
        $_now['id'] = $_rows['id'];
        $_now['nper'] = $_rows['nper'];
        $_now['thePrizeInfo'] = $_rows['thePrizeInfo'];
        $_now['vodieurl'] = 'http://www.easyhunt.cn/' . $_rows['vodieurl'];
        
        $_now = _html($_now);
        //直接打印出
        $_data['now'] = $_now;
        //查出下期预告数据信息
        $_sql1 = "SELECT * FROM tb_easySmashingInfo WHERE model = '{$_clean['model']}' AND state = 0";
        $_result1 = _query($_sql1);
        $_rows1 = _fetch_array($_result1);
        $_next = array();
        $_next['id'] = $_rows1['id'];
        $_next['nper'] = $_rows1['nper'];
        $_next['thePrizeInfo'] = $_rows1['thePrizeInfo'];
        $_next['vodieurl'] = 'http://www.easyhunt.cn/' . $_rows1['vodieurl'];
        
        $_next = _html($_next);
        
        $_data['next'] = $_next;
        //查询出中奖记录
        $_list = array();
        $_sql2 = "SELECT * FROM tb_easySmashingwinn";
        $_result2 = _query($_sql2);
        while ( $_rows2 = _fetch_array($_result2) ) {
            $_html2 = array();
            $_html2['id'] = $_rows2['id'];
            $_html2['addTimes'] = $_rows2['addTimes'];
            //奖品信息和领奖方式图片
            $_sql3 = "SELECT thePrizeInfo FROM tb_easySmashingInfo WHERE id = '{$_rows2['easySmashingInfoId']}'";
            $_result3 = _query($_sql3);
            $_rows3 = _fetch_array($_result3);
            
            $_html2['thePrizeInfo'] = $_rows3['thePrizeInfo'];
                                                                    //通过中奖记录查出用户名
            $_sql4 = "SELECT userName FROM tb_user WHERE id = '{$_rows2['user']}'";
            $_result4 = _query($_sql4);
            $_rows4 = _fetch_array($_result4);
            
            $_html2['userName'] = $_rows4['userName'];
            
            $_list[] = $_html2;
        }
        
        $_data['list'] = $_list;
        
        $_info['data'] = $_data;
    } else {
        $_info['state'] = 1;
        $_info['info'] = '参数有误!';
    }
    
    echo _json($_info);
    
    _free_result($_result);
    _free_result($_result1);
    _close();
?>
View Code

 搜索

<?php

    require dirname(__FILE__).'/includes/common.inc.php';

    $_clean = array();
    $_clean['type'] = _check($_POST['type']);//5.DH;3.MS;4.th 2:ljz 1.djz
    $_clean['content'] = _check($_POST['content']);

    define('SCRIPT','research');

    global $_pagesize,$_pagenum;

    $_productList = array();
    
    $_data = array();
    
    if ( $_clean['type'] != '' && $_clean['content'] != '' ) {
        $_productList['state'] = 0;
        $_productList['info'] = '';    
        if ( $_clean['type'] < 6 && $_clean['type'] > 2 ) {
            $_sql = "SELECT id FROM tb_easyGoods WHERE state = 1 AND goodsModule = '{$_clean['type']}' AND goodsName LIKE '%".$_clean["content"]."%' ORDER BY id DESC";
            _page($_sql,4);
            
            $_sql1 = "SELECT * FROM tb_easyGoods WHERE state = 1 AND goodsModule = '{$_clean['type']}' AND goodsName LIKE '%".$_clean["content"]."%' ORDER BY id DESC LIMIT $_pagenum,$_pagesize";
            $_result1 = _query($_sql1);
            while ( $_rows1 = _fetch_array($_result1) ) {
                $_html1 = array();
                $_html1['id'] = $_rows1['id'];
                $_html1['title'] = $_rows1['goodsName'];
                $_html1['pic'] = 'http://www.easyhunt.cn/' . $_rows1['goodsPicture'];
                $_html1['goodsMoneyPrice'] = $_rows1['goodsMoneyPrice'];
                $_html1['beginTime'] = $_rows1['beginTime'];
                $_html1['endTime'] = $_rows1['endTime'];
                $_html1 = _html($_html1);
    
                $_data[] = $_html1;
            }
            
        } elseif( $_clean['type'] < 3 && $_clean['type'] > 0 ) {
            
            $_sql = "SELECT id FROM tb_adInfo WHERE State = 1 AND adInfoType = '{$_clean['type']}' AND merchantName LIKE '%".$_clean["content"]."%' ORDER BY id DESC";
            _page($_sql,4);

            $_sql1 = "SELECT * FROM tb_adInfo WHERE State = 1 AND adInfoType = '{$_clean['type']}' AND merchantName LIKE '%".$_clean["content"]."%' ORDER BY id DESC LIMIT $_pagenum,$_pagesize";
            $_result1 = _query($_sql1);
            while( $_rows1 = _fetch_array($_result1) ) {
                $_html1 = array();
                $_html1['id'] = $_rows1['id'];
                $_html1['buyModule'] = $_rows1['buyModule'];
                $_html1['buyGoodsId'] = $_rows1['buyGoodsId'];
                $_html1['thePrizeId'] = $_rows1['thePrizeId'];
                $_html1['title'] = $_rows1['merchantName'];
                $_html1['pic'] = "http://www.easyhunt.cn/" . $_rows1['merchantPic'];
                $_html1['totalReward'] = $_rows1['totalReward'];
                $_html1['oneReward'] = $_rows1['oneReward'];
                $_html1['advertisingType'] = $_rows1['advertisingType'];
                $_html1 = _html($_html1);
                
                $_data[] = $_html1;
            }
            
        }
        $_productList['data'] = $_data;
    } else {
        $_productList['state'] = 1;
        $_productList['info'] = '参数有误!';
    }

    echo _json($_productList);

    _free_result($_result1);
    _free_result($_result2);
    _close();
?>
View Code

 查出城市区县  和所有类别

<?php
    require dirname(__FILE__).'/includes/common.inc.php';
    $_info = array();
    $_data = array();
    
    $_clean = array();
    $_clean['cityId'] = 2;
    
    if ( $_clean['cityId'] > 0 ) {
    
        $_info['state'] = 0;
        $_info['info'] = '';
        
        $_area = array();
        $_html2['id'] = '-2';
        $_html2['areaId'] = '2';
        $_html2['areaName'] = '全部区域';
        $_area[] = $_html2;
        //区县
        $_sql2 = "SELECT id,areaName,areaId,sort FROM tb_earea WHERE  areaType in (3,4) AND state = 0 ORDER BY sort ASC";
        $_result2 = _query($_sql2);
        while ( $_rows2 = _fetch_array($_result2) ) {
            $_html2 = array();
            $_html2['id'] = $_rows2['id'];
            $_html2['areaId'] = $_rows2['areaId'];
            $_html2['areaName'] = $_rows2['areaName'];
            $_html2 = _html($_html2);
            
            //$_region = array();
//            $_sql10 = "SELECT id,areaName,areaId,sort FROM tb_earea WHERE areaId = '{$_rows2['id']}' AND areaType = 4 AND state = 0 ORDER BY sort ASC";
//            $_result10 = _query($_sql10);
//            while($_rows10 = _fetch_array($_result10)){
//                $_html0 = array();
//                $_html10['id'] = $_rows10['id'];
//                $_html10['areaId'] = $_rows10['areaId'];
//                $_html10['areaName'] = $_rows10['areaName'];
//                $_html10 = _html($_html10);
//                //将信息放入$_county数组
//                $_region[] = $_html10; 
//             }
        //    $_html2['region'] = $_region;
            $_area[] = $_html2;
        }
        $_data['area'] = $_area;
        //点就赚
        $_bigClass1 = array();
        $_html3 = array();
        $_html3['id'] = '-2';
        $_html3['categoryName'] = '全部类型';    
        $_bigClass1[] = $_html3;
        $_sql3 = "SELECT id,categoryName FROM tb_ecategory WHERE grade = 1 AND categoryId = 0 AND state = 0 ORDER BY sort ASC";
        $_result3 = _query($_sql3);
        while ( $_rows3 = _fetch_array($_result3) ) {
            $_html3 = array();
            $_html3['id'] = $_rows3['id'];
            $_html3['categoryName'] = $_rows3['categoryName'];
            $_html3 = _html($_html3);
            
            $_bigClass1[] = $_html3;
        }
        $_data['djz_bigClass'] = $_bigClass1;
        
        $_smallClass = array();
        $_html4 = array();
        $_html4['id'] = '-2';
        $_html4['categoryName'] = '全部小类';
        $_smallClass[] = $_html4;
        $_sql4 = "SELECT id,categoryName FROM tb_ecategory WHERE grade=1 and categoryId=1 AND state = 0 ORDER BY sort ASC";
        $_result4 = _query($_sql4);
        while ( $_rows4 = _fetch_array($_result4) ) {
            $_html4 = array();
            $_html4['id'] = $_rows4['id'];
            $_html4['categoryName'] = $_rows4['categoryName'];
            $_html4 = _html($_html4);
            
            $_smallClass[] = $_html4;
        }
        $_data['djz_smallClass'] = $_smallClass;
        //来就赚大类
        $_bigClass2 = array();
        $_sql5 = "SELECT id,categoryName FROM tb_ecategory WHERE grade = 2 AND categoryId = 0 AND state = 0 ORDER BY sort ASC";
        $_result5= _query($_sql5);
        while ( $_rows5 = _fetch_array($_result5) ) {
            $_html5 = array();
            $_html5['id'] = $_rows5['id'];
            $_html5['categoryName'] = $_rows5['categoryName'];
            $_html5 = _html($_html5);
            $_bigClass2[] = $_html5;
        }
        $_data['ljz_bigClass'] = $_bigClass2;
        
        $_smallClass1 = array();
        $_html9 = array();
        $_sql9 = "SELECT id,categoryName FROM tb_ecategory WHERE grade=2 and categoryId=1 AND state = 0 ORDER BY sort ASC";
        $_result9 = _query($_sql9);
        while ( $_rows9 = _fetch_array($_result9) ) {
            $_html9 = array();
            $_html9['id'] = $_rows9['id'];
            $_html9['categoryName'] = $_rows9['categoryName'];
            $_html9 = _html($_html9);
            
            $_smallClass1[] = $_html9;
        }
        $_data['ljz_smallClass'] = $_smallClass1;
        
        //秒杀
        $_bigClass3 = array();
        $_sql6 = "SELECT id,categoryName FROM tb_ecategory WHERE grade = 4 AND categoryId = 0 AND state = 0 ORDER BY sort ASC";
        $_result6= _query($_sql6);
        while ( $_rows6 = _fetch_array($_result6) ) {
            $_html6 = array();
            $_html6['id'] = $_rows6['id'];
            $_html6['categoryName'] = $_rows6['categoryName'];
            $_html6 = _html($_html6);
            $_bigClass3[] = $_html6;
        }
        $_data['ms_bigClass'] = $_bigClass3;
        
        //特惠
        $_bigClass4 = array();
        $_sql7 = "SELECT id,categoryName FROM tb_ecategory WHERE grade = 5 AND categoryId = 0 AND state = 0 ORDER BY sort ASC";
        $_result7= _query($_sql7);
        while ( $_rows7 = _fetch_array($_result7) ) {
            $_html7 = array();
            $_html7['id'] = $_rows7['id'];
            $_html7['categoryName'] = $_rows7['categoryName'];
            $_html7 = _html($_html7);
            $_bigClass4[] = $_html7;
        }
        $_data['th_bigClass'] = $_bigClass4;
        //兑换
        $_bigClass5 = array();
        $_sql8 = "SELECT id,categoryName FROM tb_ecategory WHERE grade = 6 AND categoryId = 0 AND state = 0 ORDER BY sort ASC";
        $_result8= _query($_sql8);
        while ( $_rows8 = _fetch_array($_result8) ) {
            $_html8 = array();
            $_html8['id'] = $_rows8['id'];
            $_html8['categoryName'] = $_rows8['categoryName'];
            $_html8 = _html($_html8);
            $_bigClass5[] = $_html8;
        }
        $_data['dh_bigClass'] = $_bigClass5;
        $_info['data'] = $_data;
    } else {
        $_info['state'] = 1;
        $_info['info'] = '参数有误!';
    }
    echo _json($_info);
    _free_result($_result2);
    _free_result($_result3);
    _free_result($_result4);
    _free_result($_result5);
    _free_result($_result6);
    _free_result($_result7);
    _free_result($_result8);
    _free_result($_result9);
    _close();

?>
View Code

 

posted on 2014-10-20 19:39  西北阳仔2号  阅读(176)  评论(0)    收藏  举报
页脚Html代码