GoodsService.php 900 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace app\admin\service\statistics;
  3. use app\model\Goods;
  4. use app\model\GoodsRunning;
  5. use app\model\SysCategory;
  6. class GoodsService
  7. {
  8. public static function getGoods()
  9. {
  10. $categoryPath = SysCategory::where('category_id', 5)->value('category_super_path');
  11. $categoryPath .= '#5#';
  12. $categoryIds = SysCategory::where('category_super_path', 'like', $categoryPath . '%')->pluck('category_id')->toArray();
  13. $categoryIds[] = 5;
  14. if (!empty($categoryIds)) {
  15. $categoryId = $categoryIds;
  16. } else {
  17. $categoryId = [5];
  18. }
  19. $data['storageWarning'] = GoodsRunning::leftJoin('goods','goods.goods_id','=','goods_running.join_running_goods_id')
  20. ->where("goods_running_storage",'<=',2)
  21. ->whereIn('goods.join_goods_category_id',$categoryId)
  22. ->count();
  23. return $data;
  24. }
  25. }