CpItemClass.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace bizGhs\cp\classes;
  3. use bizGhs\base\classes\BaseClass;
  4. use bizGhs\product\classes\ProductClass;
  5. use common\components\imgUtil;
  6. class CpItemClass extends BaseClass
  7. {
  8. public static $baseFile = '\bizGhs\cp\models\CpItem';
  9. public static function getItemList($where)
  10. {
  11. $data = self::getList('*', $where, 'addTime DESC');
  12. $list = $data['list'] ?? [];
  13. if (!empty($list)) {
  14. $ids = array_column($list, 'productId');
  15. $infoList = ProductClass::getAllByCondition(['id' => ['in', $ids]], null, '*', 'id');
  16. foreach ($data['list'] as $key => $val) {
  17. $productId = $val['productId'] ?? 0;
  18. $info = $infoList[$productId] ?? [];
  19. $shortCover = $info['cover'] ?? '';
  20. $cover = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_130,w_130";
  21. $bigCover = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_700,w_700";
  22. $info['shortCover'] = $shortCover;
  23. $info['cover'] = $cover;
  24. $info['bigCover'] = $bigCover;
  25. $data['list'][$key]['detail'] = $info;
  26. }
  27. }
  28. return $data;
  29. }
  30. }