Browse Source

批发列表

lizhen_gitee 1 year ago
parent
commit
1e0beb91e1
2 changed files with 14 additions and 11 deletions
  1. 12 11
      addons/unishop/controller/Product.php
  2. 2 0
      addons/unishop/model/Order.php

+ 12 - 11
addons/unishop/controller/Product.php

@@ -16,7 +16,7 @@ use think\Db;
  */
 class Product extends Base
 {
-    protected $noNeedLogin = ['detail', 'lists','index_sifang','cate_list'];
+    protected $noNeedLogin = ['detail', 'lists','pifa_lists','index_sifang','cate_list'];
 
     /**
      * @ApiTitle    (产品详情)
@@ -172,23 +172,24 @@ class Product extends Base
     public function pifa_lists(){
         $page = $this->request->request('page', 1);
         $pagesize = $this->request->request('listrow', 10);
-        $by = $this->request->request('by', 'weigh');
-        $desc = $this->request->request('desc', 'desc');
 
         $result = Db::name('unishop_order_product')->alias('op')
             ->join('unishop_order o','op.order_id = o.id','LEFT')
-            ->where(['o.status' => 1,'o.have_paid' => 1])
+            ->join('user','op.user_id = user.id','LEFT')
+            ->where(['o.status' => 1,'o.have_paid' => ['GT',0]])
             ->page($page, $pagesize)
-            ->order($by, $desc)
-            ->field('id,title,image,sales_price,sales,real_sales')
+            ->order('op.id desc')
+//            ->group('op.user_product')
+            ->group('op.user_id,op.product_id')
+            ->field('product_id,title,image,pifa_price as price,user.nickname,user.avatar,sum(pifa_stock) as pifa_stock')
             ->select();
 
-        if ($result) {
-            $result = collection($result)->toArray();
-        } else {
-            $this->success(1,[]);
+        $list = list_domain_image($result,['image','avatar']);
+        foreach($list as $key => &$val){
+            $val['product_id'] = \addons\unishop\extend\Hashids::encodeHex($val['product_id']);
         }
-        $this->success('', $result);
+
+        $this->success(1, $list);
     }
 
     //首页商品四方列表

+ 2 - 0
addons/unishop/model/Order.php

@@ -285,9 +285,11 @@ class Order extends Model
                 'flash_id' => $data['flash_id'] ?? 0, // 秒杀id
 
                 //追加
+                'user_product'=> $userId.'_'.$product['id'],
                 'pifa_number' => $product['pifa_number'],
                 'pifa_price'  => $product['pifa_price'],
                 'pifa_shouyi' => $product['pifa_shouyi'],
+                'pifa_stock'  => bcmul($product['pifa_number'],$numbers[$key],0),
 
             ];