123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- <?php
- namespace app\common\model;
- use think\facade\Db;
- class Chain extends BaseModel
- {
- const STATE1 = 1;
- const STATE0 = 0;
- const STATE10 = 10;
- const STATE20 = 20;
- private $state = array(
- self::STATE0 => '关闭', self::STATE1 => '开启', self::STATE10 => '等待审核', self::STATE20 => '审核失败'
- );
- public $page_info;
-
- public function addChain($data)
- {
- return Db::name('chain')->insertGetId($data);
- }
-
- public function getChainList($condition, $pagesize = 0, $order = 'chain_id desc')
- {
- if($pagesize){
- $res = Db::name('chain')->where($condition)->order($order)->paginate(['list_rows'=>$pagesize,'query' => request()->param()],false);
- $this->page_info=$res;
- return $res->items();
- }else{
- return Db::name('chain')->where($condition)->order($order)->select()->toArray();
- }
- }
-
- public function getChainWaitVerifyList($condition, $pagesize = 0, $order = 'chain_id desc')
- {
- $condition[]=array('chain_state','=',self::STATE10);
- return $this->getChainList($condition, $pagesize, $order);
- }
-
- public function getChainWaitVerifyCount($condition)
- {
- $condition[]=array('chain_state','=',self::STATE10);
- return Db::name('chain')->where($condition)->count();
- }
-
- public function getChainOpenList($condition, $pagesize = 0, $order = 'chain_id desc')
- {
- $condition[]=array('chain_state','=',self::STATE1);
- return $this->getChainList($condition, $pagesize, $order);
- }
-
- public function getChainInfo($condition, $field = '*')
- {
- return Db::name('chain')->where($condition)->field($field)->find();
- }
-
- public function getChainOpenInfo($condition, $field = '*')
- {
- $condition[]=array('chain_state','=',self::STATE1);
- return Db::name('chain')->where($condition)->field($field)->find();
- }
-
- public function getChainFailInfo($condition, $field = '*')
- {
- $condition[]=array('chain_state','=',self::STATE20);
- return Db::name('chain')->where($condition)->field($field)->find();
- }
-
- public function editChain($update, $condition)
- {
- return Db::name('chain')->where($condition)->update($update);
- }
-
-
- public function delChain($condition) {
- return Db::name('chain')->where($condition)->delete();
- }
-
-
- public function getChainState()
- {
- return $this->state;
- }
- }
|