Erpgg.php 3.75 KB
<?php
/**
 * tpshop
 * ============================================================================
 * * 版权所有 2015-2027 深圳搜豹网络科技有限公司,并保留所有权利。
 * 网站地址: http://www.tpshop.cn
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
 * 不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * $Author: IT宇宙人 2015-08-10 $
 *
 * TPshop为照顾新手,让新手们都能读懂代码,将代码写的比较通俗易懂,不写太过高深代码。
 */ 
namespace app\home\controller; 
use think\Controller;
use Think\Exception;
use think\Url;
use think\Config;
use think\Page;
use think\Verify;
use think\Db;
use think\Cookie;
use think\Cache;



class Erpgg extends Base {

    public function _initialize() {


        define('MODULE_NAME',$this->request->module());  // 当前模块名称是
        define('CONTROLLER_NAME',$this->request->controller()); // 当前控制器名称
        define('ACTION_NAME',$this->request->action()); // 当前操作名称是
        define('PREFIX',C('database.prefix')); // 数据库表前缀
    }

    public function index(){


        $stoid=I('stoid/d',0);
        if (empty($stoid)) {
            return $this->fetch();
        }

        //SELECT * from wxd_ad where  store_id=1 and pid=601 and (intype=0   or (intype=2 and find_in_set('2192',pickup_listid)>0) or  ad_Id not IN(SELECT ad_id from wxd_ad  where  store_id=1 and pid=601 and (intype=1 and find_in_set('2192',pickup_listid)>0)))

        $getpickupid=I('pickupid');


        $where="pid=601 and enabled = 1 and start_time <= " . time() ." and end_time >= " . time() . " and store_id=".$stoid;
        $where1="";
        if ($getpickupid)
        {
            /*--
            $where1="(intype=0   or (intype=2 and find_in_set(".$getpickupid.",pickup_listid)>0)  or ad_id not in(select ad_id from wxd_ad where $where and  (intype=1 and find_in_set(".$getpickupid.",pickup_listid)>0) ))";--*/

            $where1="(intype=0  or (intype=2 and find_in_set(".$getpickupid.",pickup_listid)>0)  or (intype=1 and find_in_set(".$getpickupid.",pickup_listid)<=0))";
        }


        $adimg=M('ad')
            ->where($where)
            ->where($where1)
            ->order('orderby asc')
            ->select();


        if (empty($adimg))
        {
            return $this->fetch();
        }
        $newimglist=array();
        $ni=0;
        foreach ($adimg as $k=>$v)
        {
            $adcodeimg=explode(',',$v['ad_code']);
            $url_len = count($adcodeimg);
            for ($i = 0; $i < $url_len; $i++) {
                $newimglist[$ni]['ad_code']=$adcodeimg[$i];
                $ni=$ni+1;
            }

        }


        $this->assign('adimg',$newimglist);
        return $this->fetch();
    }


    public function index1(){


        $stoid=I('stoid/d',0);
        if (empty($stoid)) {
            return $this->fetch();
        }
        $adimg=M('ad')->where("pid=601 and enabled = 1 and start_time <= " . time() ." and end_time >= " . time() . " and store_id=".$stoid)->order('orderby asc')->select();
        if (empty($adimg))
        {
            return $this->fetch();
        }
        $newimglist=array();
        $ni=0;
        foreach ($adimg as $k=>$v)
        {
            $adcodeimg=explode(',',$v['ad_code']);
            $url_len = count($adcodeimg);
            for ($i = 0; $i < $url_len; $i++) {
                $newimglist[$ni]['ad_code']=$adcodeimg[$i];
                $ni=$ni+1;
            }

        }


        $this->assign('adimg',$newimglist);
        return $this->fetch();
    }

}