Răsfoiți Sursa

用户求购

afa 7 luni în urmă
părinte
comite
235abae713

+ 4 - 2
application/api/controller/Market.php

@@ -86,8 +86,10 @@ class Market extends Api
     //求购列表
     public function buyingList(ProductBuying $productBuying)
     {
-      
-        $this->success('ok', $productBuying::getBuyingList($this->auth->id, $this->request->getLan(), $this->pageSize));
+        $params = $this->request->post();
+        $validate = \think\Loader::validate('Market');
+        if(!$validate->scene('announcement')->check($params)) $this->error($validate->getError());
+        $this->success('ok', $productBuying::getBuyingList($params['product_id']));
     }
 
     /**

+ 7 - 1
application/api/controller/User.php

@@ -10,7 +10,7 @@ use app\common\model\LedgerWalletModel;
 use app\common\model\ProductTransfer;
 use app\common\model\TeamLevelModel;
 use app\common\model\UserModel;
-use app\common\model\ParametersModel;
+use app\common\model\ProductBuying;
 use app\common\model\UserArea;
 use fast\Action;
 use fast\Asset;
@@ -161,6 +161,12 @@ class User extends Api
         $this->success('', $list);
     }
 
+    //求购列表
+    public function getBuyingList(ProductBuying $productBuying)
+    {
+        $this->success('ok', $productBuying::getUserBuyingList($this->auth->id, $this->lan, $this->pageSize));
+    }
+
     /**
      * 修改个人信息
      * @return void

+ 12 - 6
application/common/model/ProductBuying.php

@@ -76,15 +76,21 @@ class ProductBuying extends Model
     }
 
     //获取订单列表
-    public static function getBuyingList(int $uid, string $lan, int $page)
+    public static function getBuyingList(int $productId)
     {
-        return self::alias('a')->where('user_id', $uid)
-        ->join('product_list p', 'a.product_id = p.id')
-        ->field('a.*,p.' . $lan . '_name as name,p.thum')
-        ->order('id desc')
-        ->paginate($page);
+        return self::where('product_id', $productId)->where('status', self::Normal)->field('id,min_price')->order('id desc')->select();
     }
 
+       //获取订单列表
+       public static function getUserBuyingList(int $uid, string $lan, int $page)
+       {
+           return self::alias('a')->where('user_id', $uid)
+           ->join('product_list p', 'a.product_id = p.id')
+           ->field('a.*,p.' . $lan . '_name as name,p.thum')
+           ->order('id desc')
+           ->paginate($page);
+       }
+
     public function getCreateTimeTextAttr($value, $data)
     {
         $value = $value ? $value : (isset($data['create_time']) ? $data['create_time'] : '');