Browse Source

Nft列表添加商品搜索

afa 9 months ago
parent
commit
dd29d12d5d
1 changed files with 5 additions and 3 deletions
  1. 5 3
      application/api/controller/User.php

+ 5 - 3
application/api/controller/User.php

@@ -71,7 +71,8 @@ class User extends Api
     public function getNftList(ProductOrder $productOrder)
     {
         $typeId = $this->request->post('type_id/d', 0);
-        $where = self::getNftWhere($typeId, $productOrder);
+        $productId = $this->request->post('product_id/d', 0);
+        $where = self::getNftWhere($typeId, $productId, $productOrder);
         $list = $productOrder->alias('a')
               ->join("product_list b", "b.id = a.product_id", "left")
               ->join("products c", "c.id = b.type_id", "left")
@@ -93,7 +94,7 @@ class User extends Api
     public function getMyNftList(ProductOrder $productOrder)
     {
         $typeId = $this->request->post('type_id/d', 0);
-        $where = self::getNftWhere($typeId, $productOrder);
+        $where = self::getNftWhere($typeId, 0, $productOrder);
         $list = $productOrder->alias('a')
               ->join("product_list b", "b.id = a.product_id", "left")
               ->field('a.id as order_id,a.product_id,'.'b.'.$this->lan.'_name as name,b.thum as img_url,a.price,a.status,a.type_id, count(a.num) as hold_num')
@@ -212,7 +213,7 @@ class User extends Api
      * Nft搜索条件
      * @return array
      */
-    private static function getNftWhere(int $typeId, object  $productOrder): array
+    private static function getNftWhere(int $typeId, int $productId , object  $productOrder): array
     {   
         $where = [];
         switch ($typeId) {
@@ -235,6 +236,7 @@ class User extends Api
                 $where = ['a.type_id' => $productOrder::Popular, 'a.status' => $productOrder::Shipped];
                 break;
         }
+        if($productId > 0) $where['a.product_id'] = ['=' , $productId];
         return $where;
     }