PayPlugin.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace app\user\model;
  3. use think\Model;
  4. class PayPlugin extends Model{
  5. protected $updateTime = 'update_time'; // 每次更新时间
  6. protected $autoWriteTimestamp = 'datetime'; // 开启自动写入时间戳字段
  7. public function initialize(){
  8. parent::initialize();
  9. }
  10. /**
  11. * 获取数据信息
  12. * @param int $page 页码
  13. * @param array $where 查询条件
  14. */
  15. public function getInfo($page, $where = array()){
  16. return $this->db()
  17. ->where($where)
  18. ->page($page, config('paginate.list_rows'))
  19. ->select();
  20. }
  21. /**
  22. * 获取分页信息
  23. * @param array $where 查询条件
  24. */
  25. public function getPage($where = array()){
  26. $query = getPaginatiorQuery();
  27. $total = $this->db()->where($where)->count();
  28. // 查询条件
  29. $config = ['query'=>$query];
  30. $paginate = $this->db()->where($where)->paginate(config('paginate.list_rows'), $total, $config);
  31. return $paginate->render();
  32. }
  33. /**
  34. * 根据id找到支付信息
  35. * @param int $id
  36. * @return array|\think\db\false|PDOStatement|string|\think\Model
  37. */
  38. public function getPayPluginById($id){
  39. return $this->db()->where(['id'=>$id])->find();
  40. }
  41. /**
  42. * 根据状态找到支付信息
  43. * @param int $type
  44. * @return mixed|array|array[]|object[]
  45. */
  46. public function getPayPluginByType($type){
  47. return $this->db()->where(['type'=>$type])->find()->getData();
  48. }
  49. }