0
0

MateSubGoods.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace app\common\model;
  3. use think\Db;
  4. class MateSubGoods extends Base
  5. {
  6. protected $createTime = 'create_time';
  7. protected $updateTime = 'update_time';
  8. public $table = 'mate_sub_goods';
  9. protected $validateName = 'MateSubGoods';
  10. public function getList($offset,$size,$where,$order){
  11. $list =$this
  12. ->where($where)
  13. ->limit($offset,$size)
  14. ->order($order)
  15. ->select()
  16. ->toArray();
  17. foreach ($list as $k=>$v){
  18. $pInfo =Db::name('mate_goods')
  19. ->where('id',$v['pid'])
  20. ->find();
  21. $list[$k]['title'] = $pInfo?$pInfo['title']:"";
  22. $list[$k]['type'] = $pInfo?$pInfo['type']:"";
  23. $list[$k]['unit'] = $pInfo?$pInfo['unit']:"";
  24. $list[$k]['brand'] = $pInfo?$pInfo['brand']:"";
  25. $list[$k]['buy_time'] = $pInfo?$pInfo['buy_time']:"";
  26. $list[$k]['spec'] = $pInfo?$pInfo['spec']:"";
  27. }
  28. return $list;
  29. }
  30. public function getByList($where){
  31. $list =$this
  32. ->where($where)
  33. ->where('nums','>',0)
  34. ->select();
  35. $list = $list?$list->toArray():[];
  36. foreach ($list as $k=>$v){
  37. $pInfo =Db::name('mate_goods')
  38. ->where('id',$v['pid'])
  39. ->find();
  40. $list[$k]['title'] = $pInfo?$pInfo['title']:"";
  41. $list[$k]['type'] = $pInfo?$pInfo['type']:"";
  42. $list[$k]['unit'] = $pInfo?$pInfo['unit']:"";
  43. $list[$k]['brand'] = $pInfo?$pInfo['brand']:"";
  44. $list[$k]['buy_time'] = $pInfo?$pInfo['buy_time']:"";
  45. $list[$k]['spec'] = $pInfo?$pInfo['spec']:"";
  46. }
  47. return $list;
  48. }
  49. }