Răsfoiți Sursa

没有删除的广告

shish 6 ani în urmă
părinte
comite
76a2e63d16
1 a modificat fișierele cu 129 adăugiri și 128 ștergeri
  1. 129 128
      biz/ad/classes/AdClass.php

+ 129 - 128
biz/ad/classes/AdClass.php

@@ -8,132 +8,133 @@ use \biz\base\classes\BaseClass;
 
 class AdClass extends BaseClass
 {
-	
-	public static $baseFile = '\biz\ad\models\Ad';
-	
-	//取出有效的广告 shish 2019.12.13
-	public static function getValidAdList($merchantId)
-	{
-		$time = time();
-		$list = self::getAllByCondition([
-			'merchantId' => $merchantId,
-			'type' => 1,
-			'status' => 1,
-			'startTime<' => $time,
-			'endTime>' => $time
-		], 'inTurn DESC', '*');
-		return !empty($list) ? self::groupBaseInfo($list) : [];
-	}
-	
-	//广告列表 shish 2019.12.
-	public static function getAdList($where)
-	{
-		$data = self::getList('*', $where, 'inTurn DESC,updateTime DESC');
-		$list = $data['list'];
-		if (!empty($list)) {
-			$imgUrl = Yii::$app->params['imgHost'];
-			foreach ($list as $key => $val) {
-				//图片提供完整地址给前端,同时原有addImg字段不占用,定义新字段adImgUrl
-				$list[$key]['adImgUrl'] = $imgUrl . $val['adImg'];
-				$style = $val['style'];
-				$url = $val['url'];
-				if ($style == 1) {
-					//商品地址后面再补写
-					$url = '';
-				}
-				$list[$key]['url'] = $url;
-			}
-		}
-		$data['list'] = $list;
-		return $data;
-	}
-	
-	//添加广告
-	public static function addAd($data)
-	{
-		//永久有效
-		$time = time();
-		$neverExpireTime = Yii::$app->params['neverExpireTime'];
-		if (isset($data['endTime']) && empty($data['endTime'])) {
-			$data['startTime'] = $time;
-			$data['endTime'] = $neverExpireTime;
-		} else {
-			$data['startTime'] = strtotime($data['startTime']);
-			$data['endTime'] = strtotime($data['endTime']);
-		}
-		return self::add($data);
-	}
-	
-	//组装通用的信息
-	public static function groupBaseInfo($list)
-	{
-		$imgUrl = Yii::$app->params['imgHost'];
-		foreach ($list as $key => $val) {
-			$style = $val['style'];
-			$url = $val['url'];
-			if ($style == 1) {
-				$url = '';
-			}
-			$list[$key]['url'] = $url;
-			$list[$key]['adImgUrl'] = $imgUrl . $val['adImg'];
-		}
-		return $list;
-	}
-	
-	//单个广告的信息
-	public static function getDetail($id)
-	{
-		$info = self::getById($id);
-		if (empty($info)) {
-			util::fail('找不到广告');
-		}
-		$list = self::groupBaseInfo([$info]);
-		return current($list);
-	}
-	
-	//点击数+1
-	public static function clickAd($id)
-	{
-		return self::counters(['viewTimes' => 1], ['id' => $id]);
-	}
-	
-	//更新广告
-	public static function updateAd($id, $data)
-	{
-		$time = time();
-		//广告类型不允许修改
-		unset($data['type']);
-		$neverExpireTime = Yii::$app->params['neverExpireTime'];
-		if (isset($data['endTime']) && empty($data['endTime'])) {
-			$data['startTime'] = $time;
-			$data['endTime'] = $neverExpireTime;
-		} else {
-			$data['startTime'] = strtotime($data['startTime']);
-			$data['endTime'] = strtotime($data['endTime']);
-		}
-		return self::updateById($id, $data);
-	}
-	
-	//开店广告初始化 shish 2020.2.14
-	public static function initAdd($merchantId)
-	{
-		$time = time();
-		$imgHost = Yii::$app->params['imgHost'];
-		$list = [
-			['adName' => '培训图', 'adImg' => $imgHost . '/example/mall/1.jpg', 'type' => 0, 'startTime' => 0, 'endTime' => 4102416000, 'addTime' => $time, 'merchantId' => $merchantId, 'status' => 1],
-			['adName' => '花礼', 'adImg' => $imgHost . '/example/mall/2.jpg', 'type' => 0, 'startTime' => 0, 'endTime' => 4102416000, 'addTime' => $time, 'merchantId' => $merchantId, 'status' => 1],
-			['adName' => '花艺', 'adImg' => $imgHost . '/example/mall/3.jpg', 'type' => 0, 'startTime' => 0, 'endTime' => 4102416000, 'addTime' => $time, 'merchantId' => $merchantId, 'status' => 1],
-			['adName' => '门店图片', 'adImg' => $imgHost . '/example/shop/1.jpg', 'type' => 1, 'startTime' => 0, 'endTime' => 4102416000, 'addTime' => $time, 'merchantId' => $merchantId, 'status' => 1],
-		];
-		foreach ($list as $val) {
-			self::add($val);
-		}
-	}
-	
-	//删除广告 shish 2020.5.21
-	public static function deleteAd($id)
-	{
-		self::updateById($id, ['delStatus' => 1]);
-	}
-	
+
+    public static $baseFile = '\biz\ad\models\Ad';
+
+    //取出有效的广告 shish 2019.12.13
+    public static function getValidAdList($merchantId)
+    {
+        $time = time();
+        $list = self::getAllByCondition([
+            'merchantId' => $merchantId,
+            'delStatus' => 0,
+            'type' => 1,
+            'status' => 1,
+            'startTime<' => $time,
+            'endTime>' => $time
+        ], 'inTurn DESC', '*');
+        return !empty($list) ? self::groupBaseInfo($list) : [];
+    }
+
+    //广告列表 shish 2019.12.
+    public static function getAdList($where)
+    {
+        $data = self::getList('*', $where, 'inTurn DESC,updateTime DESC');
+        $list = $data['list'];
+        if (!empty($list)) {
+            $imgUrl = Yii::$app->params['imgHost'];
+            foreach ($list as $key => $val) {
+                //图片提供完整地址给前端,同时原有addImg字段不占用,定义新字段adImgUrl
+                $list[$key]['adImgUrl'] = $imgUrl . $val['adImg'];
+                $style = $val['style'];
+                $url = $val['url'];
+                if ($style == 1) {
+                    //商品地址后面再补写
+                    $url = '';
+                }
+                $list[$key]['url'] = $url;
+            }
+        }
+        $data['list'] = $list;
+        return $data;
+    }
+
+    //添加广告
+    public static function addAd($data)
+    {
+        //永久有效
+        $time = time();
+        $neverExpireTime = Yii::$app->params['neverExpireTime'];
+        if (isset($data['endTime']) && empty($data['endTime'])) {
+            $data['startTime'] = $time;
+            $data['endTime'] = $neverExpireTime;
+        } else {
+            $data['startTime'] = strtotime($data['startTime']);
+            $data['endTime'] = strtotime($data['endTime']);
+        }
+        return self::add($data);
+    }
+
+    //组装通用的信息
+    public static function groupBaseInfo($list)
+    {
+        $imgUrl = Yii::$app->params['imgHost'];
+        foreach ($list as $key => $val) {
+            $style = $val['style'];
+            $url = $val['url'];
+            if ($style == 1) {
+                $url = '';
+            }
+            $list[$key]['url'] = $url;
+            $list[$key]['adImgUrl'] = $imgUrl . $val['adImg'];
+        }
+        return $list;
+    }
+
+    //单个广告的信息
+    public static function getDetail($id)
+    {
+        $info = self::getById($id);
+        if (empty($info)) {
+            util::fail('找不到广告');
+        }
+        $list = self::groupBaseInfo([$info]);
+        return current($list);
+    }
+
+    //点击数+1
+    public static function clickAd($id)
+    {
+        return self::counters(['viewTimes' => 1], ['id' => $id]);
+    }
+
+    //更新广告
+    public static function updateAd($id, $data)
+    {
+        $time = time();
+        //广告类型不允许修改
+        unset($data['type']);
+        $neverExpireTime = Yii::$app->params['neverExpireTime'];
+        if (isset($data['endTime']) && empty($data['endTime'])) {
+            $data['startTime'] = $time;
+            $data['endTime'] = $neverExpireTime;
+        } else {
+            $data['startTime'] = strtotime($data['startTime']);
+            $data['endTime'] = strtotime($data['endTime']);
+        }
+        return self::updateById($id, $data);
+    }
+
+    //开店广告初始化 shish 2020.2.14
+    public static function initAdd($merchantId)
+    {
+        $time = time();
+        $imgHost = Yii::$app->params['imgHost'];
+        $list = [
+            ['adName' => '培训图', 'adImg' => $imgHost . '/example/mall/1.jpg', 'type' => 0, 'startTime' => 0, 'endTime' => 4102416000, 'addTime' => $time, 'merchantId' => $merchantId, 'status' => 1],
+            ['adName' => '花礼', 'adImg' => $imgHost . '/example/mall/2.jpg', 'type' => 0, 'startTime' => 0, 'endTime' => 4102416000, 'addTime' => $time, 'merchantId' => $merchantId, 'status' => 1],
+            ['adName' => '花艺', 'adImg' => $imgHost . '/example/mall/3.jpg', 'type' => 0, 'startTime' => 0, 'endTime' => 4102416000, 'addTime' => $time, 'merchantId' => $merchantId, 'status' => 1],
+            ['adName' => '门店图片', 'adImg' => $imgHost . '/example/shop/1.jpg', 'type' => 1, 'startTime' => 0, 'endTime' => 4102416000, 'addTime' => $time, 'merchantId' => $merchantId, 'status' => 1],
+        ];
+        foreach ($list as $val) {
+            self::add($val);
+        }
+    }
+
+    //删除广告 shish 2020.5.21
+    public static function deleteAd($id)
+    {
+        self::updateById($id, ['delStatus' => 1]);
+    }
+
 }