GoodsService.php 728 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace app\common\service;
  3. use app\common\constant\CommonConstant;
  4. use app\common\model\Goods;
  5. /**
  6. * 商品服务类
  7. */
  8. class GoodsService
  9. {
  10. /**
  11. * 商品列表
  12. *
  13. * @param integer $category_id 二级分类ID
  14. * @return array
  15. **/
  16. public static function get_list($category_id)
  17. {
  18. $list = Goods::field('status,is_deleted,create_at', true)
  19. ->where('goods_category_id', $category_id)
  20. ->where('status', CommonConstant::IS_WHO_1)
  21. ->where('is_deleted', CommonConstant::IS_DELETED_0)
  22. ->with([
  23. 'goodsSku'
  24. ])
  25. ->order('weigh desc,id desc')
  26. ->select();
  27. return $list;
  28. }
  29. }