SiteProduct.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\model\system;
  4. use library\traits\JwtAuthModelTrait;
  5. use library\traits\ModelTrait;
  6. use think\Exception;
  7. use think\Model;
  8. /**
  9. * @mixin \think\Model
  10. */
  11. class SiteProduct extends Model
  12. {
  13. use ModelTrait;
  14. use JwtAuthModelTrait;
  15. private $sassid;
  16. public function setSassid($sassid) {
  17. $this->sassid = $sassid;
  18. }
  19. /**
  20. * 获取列表数据
  21. * @param $page
  22. * @param $where
  23. * @param $pageCount
  24. * @param $desc
  25. */
  26. public function getList($page = 1,$where = [],$pageCount = 20){
  27. $data =
  28. $this->field("sp.id,p.title,img,sp.price,p.commission,sp.status,sp.sales,sp.is_new,sp.is_host,sp.ver_bug_count,p.count")
  29. ->alias("sp")
  30. ->join("product p","p.id = sp.p_id","left")
  31. ->where('sp.sassid',$this->sassid)
  32. ->when(!empty($where),function ($query) use($where){
  33. if(!empty($where['type'])) {
  34. if($where['type'] == 'kc') {
  35. $query->where('p.count','>',0);
  36. }
  37. if($where['type'] == 'nkc') {
  38. $query->where('p.count','=',0);
  39. }
  40. }
  41. })
  42. ->paginate(['list_rows'=>$pageCount,'page'=>$page])
  43. ->toArray();
  44. return [$data['total'],$data['data']];
  45. }
  46. }