WechatPlan.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace app\admin\model;
  3. use think\Model;
  4. class WechatPlan extends Model
  5. {
  6. // 自动写入时间戳字段
  7. protected $autoWriteTimestamp = 'int';
  8. // 定义时间戳字段名
  9. protected $createTime = 'createtime';
  10. protected $updateTime = 'updatetime';
  11. public function getHidedataList()
  12. {
  13. return ['0' => __('Hidedata 0'), '1' => __('Hidedata 1')];
  14. }
  15. public function getHidedataTextAttr($value, $data)
  16. {
  17. $value = $value ? $value : (isset($data['hidedata']) ? $data['hidedata'] : '');
  18. $list = $this->getHidedataList();
  19. return isset($list[$value]) ? $list[$value] : '';
  20. }
  21. public static function lst($where)
  22. {
  23. $model = new self;
  24. $xwhere = null;
  25. $order = "id desc";
  26. if (isset($where['cid']) && $where['cid'] > 0) $xwhere['cid'] = $where['cid'];
  27. if (isset($where['plan_id']) && $where['plan_id'] > 0) $xwhere['plan_id'] = $where['plan_id'];
  28. // if (isset($where['paid']) && $where['paid'] > -1) $xwhere['paid'] = $where['paid'];
  29. // if (isset($where['help_id']) && $where['help_id'] > -1) $xwhere['help_id'] = $where['help_id'];
  30. // if (isset($where['order']) && $where['order'] != '') $order = $where['order'];
  31. // if (isset($where['key']) && $where['key'] != '') $xwhere['name|contact|tel'] = ['like', "%{$where['key']}%"];
  32. $data = $model->where($xwhere)->where('hidedata',0)->order($order)->page($where['page'], $where['limit'])->select();
  33. $count = $model->where($xwhere)->count();
  34. return compact('count', 'data');
  35. }
  36. public static function read($where)
  37. {
  38. $model = new self;
  39. $xwhere = null;
  40. $order = "id desc";
  41. if (isset($where['id']) && $where['id'] > 0) $xwhere['id'] = $where['id'];
  42. if (isset($where['cid']) && $where['cid'] > 0) $xwhere['cid'] = $where['cid'];
  43. $data = $model->where($xwhere)->order($order)->select();
  44. // $count = $model->where($xwhere)->count();
  45. return $data;
  46. }
  47. }