Browse Source

质押列表

afa 4 months ago
parent
commit
9aad2053be
1 changed files with 14 additions and 3 deletions
  1. 14 3
      application/api/controller/Pledge.php

+ 14 - 3
application/api/controller/Pledge.php

@@ -19,7 +19,8 @@ class Pledge extends Api
 {
 {
 
 
       protected string $lan = '';
       protected string $lan = '';
-      protected $pay = [1=>'token', 2=>'teac'];
+      protected $pay   = [1=>'token', 2=>'teac'];
+      protected $order = [1=>'desc',  2=>'asc'];
 
 
       public function _initialize()
       public function _initialize()
       {
       {
@@ -32,12 +33,22 @@ class Pledge extends Api
       {     
       {     
             $type_id = $this->request->param('type_id', 0, 'intval');
             $type_id = $this->request->param('type_id', 0, 'intval');
             if(empty($type_id)) $this->error(__("参数有误,无可用产品"));
             if(empty($type_id)) $this->error(__("参数有误,无可用产品"));
-
+            $title = $this->request->param('title/s',  '');
+            $day_num = $this->request->param('day_num/d', 0);
+            $income_reta = $this->request->param('income_reta/d', 0);
+            $map = [];
+            $order = 'weigh desc,id desc';
+            if(!empty($title)) $map[] = ['title', 'LIKE', '%'.$title.'%'];
+            if ($day_num > 0)  $order = 'day_num '.$this->order[$day_num];
+            if ($income_reta > 0) $order = 'income_reta '.$this->order[$income_reta];
+            if ($day_num > 0 && $income_reta > 0) $order = 'day_num '.$this->order[$day_num].',income_reta '.$this->order[$income_reta];
+            
             $list = $productPledges
             $list = $productPledges
                   ->where('status', $productPledges::Normal)
                   ->where('status', $productPledges::Normal)
                   ->where('to_lang', $this->lan)->where('type_id', $type_id)
                   ->where('to_lang', $this->lan)->where('type_id', $type_id)
+                  ->where($map)
                   ->field('id,title,day_num,income_reta,product_id,type_id')
                   ->field('id,title,day_num,income_reta,product_id,type_id')
-                  ->order('weigh desc,id desc')
+                  ->order($order)
                   ->paginate($this->pageSize);
                   ->paginate($this->pageSize);
 
 
             $list = $pledgeLogic::getByProductIdList($list, $this->lan);  
             $list = $pledgeLogic::getByProductIdList($list, $this->lan);