Exemple #1
0
 /**
  * 触摸屏单品图片统计列表
  * */
 public static function touchclotesimagecountlist($arr = array(), $page = 1, $pagecount = 20)
 {
     $where = '1=1';
     $litiCategory = "15698,15699,15700,15700,15702,15703,15704,15705,15706,15707,15708";
     //立体图分类
     $staticCategory = "15709,15710,15711,15712,15713,15714,15715,15716";
     //有静态图的分类
     if (!empty($arr)) {
         if (!empty($arr['keyword']) && $arr['keyword'] != "根据款号模糊搜索") {
             $where .= " && brandnumber like '%" . $arr['keyword'] . "%'";
         }
         $where .= " && touchid='" . $arr['selecttouchid'] . "'";
         if (!empty($arr['startdate'])) {
             $where .= " && date_add>='" . $arr['startdate'] . "'";
         }
         if (!empty($arr['enddate'])) {
             $where .= " && date_add<'" . $arr['enddate'] . "'";
         }
         if (!empty($arr['brand'])) {
             $where .= " && brandid={$arr['brand']}";
         }
         $category1Where = "";
         $category2Where = "";
         if (!empty($arr['category1'])) {
             $category1Where = "(imagescontent NOT  LIKE '%graphicmodel%') && beu_clothes.clothescategory in (" . $litiCategory . ")";
         }
         if (!empty($arr['category2'])) {
             $category2Where = "(imagescontent NOT  LIKE '%staticImageContent%') && beu_clothes.clothescategory in (" . $staticCategory . ")";
         }
         if (!empty($arr['category1']) && !empty($arr['category2'])) {
             $where .= "&& ((" . $category1Where . ") || (" . $category2Where . "))";
         } else {
             if (!empty($arr['category1'])) {
                 $where .= " &&" . $category1Where;
             }
             if (!empty($arr['category2'])) {
                 $where .= " &&" . $category2Where;
             }
         }
     }
     //echo $where;
     $obj = Yii::app()->db->createCommand()->select('beu_clothes.id,beu_clothes.brandnumber,beu_clothes.imagescontent,beu_clothes.clothescategory,beu_clothes.brandid,beu_clothes.singlespace,touch_clothes.touchid')->from('beu_clothes')->join('touch_clothes', 'beu_clothes.id=touch_clothes.clothesid')->where($where)->order('beu_clothes.id desc')->limit($pagecount, ($page - 1) * $pagecount)->queryAll();
     //获取总个数
     $con = Yii::app()->db->createCommand()->select('beu_clothes.id,beu_clothes.brandnumber,beu_clothes.imagescontent,beu_clothes.singlespace')->from('beu_clothes')->join('touch_clothes', 'beu_clothes.id=touch_clothes.clothesid')->where($where)->queryAll();
     for ($i = 0; $i < count($obj); $i++) {
         $obj[$i]['different'] = "";
         //不同穿法
         $obj[$i]['related'] = "";
         //不同颜色
         $obj[$i]['graphicmodelcount'] = 0;
         //立体图
         $obj[$i]['collocationmapcount'] = 0;
         //搭配单品图
         $obj[$i]['staticImagecount'] = 0;
         //静态图
         $obj[$i]['detailImagecount'] = 0;
         //细节图
         if (!empty($obj[$i]['imagescontent'])) {
             $imagescontent = json_decode($obj[$i]['imagescontent'], true);
             if (isset($imagescontent['graphicmodel']) && !empty($imagescontent['graphicmodel'])) {
                 $obj[$i]['graphicmodelcount'] = count($imagescontent['graphicmodel']);
             }
             if (isset($imagescontent['collocationmap']) && !empty($imagescontent['collocationmap'])) {
                 $obj[$i]['collocationmapcount'] = count($imagescontent['collocationmap']);
             }
             if (isset($imagescontent['staticImagecontent']) && !empty($imagescontent['staticImagecontent'])) {
                 $obj[$i]['staticImagecount'] = count($imagescontent['staticImagecontent']);
             }
             if (isset($imagescontent['detailImagecontent']) && !empty($imagescontent['detailImagecontent'])) {
                 $obj[$i]['detailImagecount'] = count($imagescontent['detailImagecontent']);
             }
         }
         $differentArray = Clothes::beuDifferentSelectByClothesid($obj[$i]['id']);
         //不同穿法
         $differentCount = count($differentArray);
         if ($differentCount != 0) {
             for ($j = 0; $j < $differentCount; $j++) {
                 for ($y = 1; $y < 13; $y++) {
                     $clothesid = 'clothesid' . $y;
                     if (!empty($differentArray[$j][$clothesid])) {
                         for ($k = 0; $k < count($con); $k++) {
                             if ($con[$k]['id'] == $differentArray[$j][$clothesid]) {
                                 $obj[$i]['different'] .= $con[$k]['id'] . "-" . $con[$k]['brandnumber'] . "</br>";
                                 break;
                             }
                         }
                     }
                 }
             }
         }
         $relatedArray = Clothes::beuRelatedSelectByClothesid($obj[$i]['id']);
         //不同颜色
         $relatedCount = count($relatedArray);
         if ($relatedCount != 0) {
             for ($j = 0; $j < $relatedCount; $j++) {
                 for ($y = 1; $y < 13; $y++) {
                     $clothesid = 'clothesid' . $y;
                     if (!empty($relatedArray[$j][$clothesid])) {
                         for ($k = 0; $k < count($con); $k++) {
                             if ($con[$k]['id'] == $relatedArray[$j][$clothesid]) {
                                 $obj[$i]['related'] .= $con[$k]['id'] . "-" . $con[$k]['brandnumber'] . "</br>";
                                 break;
                             }
                         }
                     }
                 }
             }
         }
         $obj[$i]['different'] = trim($obj[$i]['different'], "</br>");
         $obj[$i]['related'] = trim($obj[$i]['related'], "</br>");
     }
     $clothescount = count($con);
     //总件数
     $Allgraphicmodelcount = 0;
     //立体图
     $AllstaticImagecount = 0;
     //静态图
     $AlldetailImagecount = 0;
     //细节图
     $noclothesimagecount = 0;
     //空单数
     $Allcollocationmapcount = 0;
     //记录搭配单品数量
     for ($i = 0; $i < count($con); $i++) {
         if (!empty($con[$i]['imagescontent'])) {
             $imagescontent = json_decode($con[$i]['imagescontent'], true);
             if (isset($imagescontent['graphicmodel']) && !empty($imagescontent['graphicmodel'])) {
                 $Allgraphicmodelcount = $Allgraphicmodelcount + count($imagescontent['graphicmodel']);
             }
             if (isset($imagescontent['collocationmap']) && !empty($imagescontent['collocationmap'])) {
                 $Allcollocationmapcount = $Allcollocationmapcount + count($imagescontent['collocationmap']);
                 //$con[$i]['singlespace']
             }
             if (isset($imagescontent['staticImagecontent']) && !empty($imagescontent['staticImagecontent'])) {
                 $AllstaticImagecount = $AllstaticImagecount + count($imagescontent['staticImagecontent']);
             }
             if (isset($imagescontent['detailImagecontent']) && !empty($imagescontent['detailImagecontent'])) {
                 $AlldetailImagecount = $AlldetailImagecount + count($imagescontent['detailImagecontent']);
             }
         }
         if ($con[$i]['singlespace'] == 0) {
             $noclothesimagecount++;
         }
     }
     //var_dump($con);
     //翻页
     $criteria = new CDbCriteria();
     $pages = new CPagination(count($con));
     $pages->pageSize = $pagecount;
     $pages->applyLimit($criteria);
     if (!empty($obj)) {
         $obj[0]["pages"] = $pages;
         $obj[0]["clothescount"] = $clothescount;
         $obj[0]["Allgraphicmodelcount"] = $Allgraphicmodelcount;
         $obj[0]["AllstaticImagecount"] = $AllstaticImagecount;
         $obj[0]["AlldetailImagecount"] = $AlldetailImagecount;
         $obj[0]["noclothesimagecount"] = $noclothesimagecount;
         $obj[0]["Allcollocationmapcount"] = $Allcollocationmapcount;
         return $obj;
     } else {
         return false;
     }
 }