| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- namespace app\admin\model;
- use think\Model;
- class WechatPlan extends Model
- {
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- public static function getNewCode()
- {
- do {
- list($msec, $sec) = explode(' ', microtime());
- $msectime = number_format((floatval($msec) + floatval($sec)) * 1000, 0, '', '');
- $orderId = 'qy' . $msectime . mt_rand(10000, 99999);
- } while (self::where(['order_id' => $orderId])->find());
- return $orderId;
- }
- public static function lst($where)
- {
- $model = new self;
- $xwhere = null;
- $order = "id desc";
- if (isset($where['cid']) && $where['cid'] > 0) $xwhere['cid'] = $where['cid'];
- if (isset($where['plan_id']) && $where['plan_id'] > 0) $xwhere['plan_id'] = $where['plan_id'];
- if (isset($where['price']) && $where['price'] > 0) $xwhere['price'] = $where['price'];
- // if (isset($where['paid']) && $where['paid'] > -1) $xwhere['paid'] = $where['paid'];
- // if (isset($where['help_id']) && $where['help_id'] > -1) $xwhere['help_id'] = $where['help_id'];
- // if (isset($where['order']) && $where['order'] != '') $order = $where['order'];
- // if (isset($where['key']) && $where['key'] != '') $xwhere['name|contact|tel'] = ['like', "%{$where['key']}%"];
- $data = $model->where($xwhere)->order($order)->page($where['page'], $where['limit'])->select();
- $count = $model->where($xwhere)->count();
- return compact('count', 'data');
- }
- public static function read($where)
- {
- $model = new self;
- $xwhere = null;
- $order = "id desc";
- if (isset($where['id']) && $where['id'] > 0) $xwhere['id'] = $where['id'];
- $data = $model->where($xwhere)->order($order)->page($where['page'], $where['limit'])->select();
- // $count = $model->where($xwhere)->count();
- return $data;
- }
- }
|