Przeglądaj źródła

客户端-增加获取商户上架的商品列表接口

sunxbiao 11 miesięcy temu
rodzic
commit
11c2fb9282

+ 4 - 24
app/common/dao/store/product/ProductDao.php

@@ -121,20 +121,9 @@ class ProductDao extends BaseDao
121 121
         $query -> where("type != 7");
122 122
         $query->withSearch($keyArray, $whereArr);
123 123
 
124
-        if($mer_type==1 && $merId==324){
125
-            $merIds=Db::name('merchant')->where('mer_type',1)->column('mer_id');
126
-            //一壶茶会员专区
127
-            $query->when($merIds, function ($query) use ($merIds) {
128
-                $query->whereIn('mer_id', $merIds);
129
-            });
130
-        }else{
131
-            $query->when(($merId !== null), function ($query) use ($merId) {
132
-                $query->where('mer_id', $merId);
133
-            });
134
-        }
135
-
136
-
137
-        $query->when(isset($where['hot_type']) && $where['hot_type'] !== '', function ($query) use ($where) {
124
+        $query->when(!empty($merId), function ($query) use ($merId) {
125
+            $query->where('mer_id', $merId);
126
+        })->when(isset($where['hot_type']) && $where['hot_type'] !== '', function ($query) use ($where) {
138 127
             if ($where['hot_type'] == 'new')
139 128
                 $query->where('is_new', 1);
140 129
             else if ($where['hot_type'] == 'hot')
@@ -162,16 +151,7 @@ class ProductDao extends BaseDao
162 151
             unset($where['keyword']);
163 152
         })->when(isset($where['volunteer']),function ($query) use ($where){
164 153
             $query-> where('volunteer',$where['volunteer']);
165
-        });
166
-        $source = request()->header('source');
167
-        $merId= request()->header('merId');
168
-        if($source=='yhc' && $merId){
169
-//            $query->where('spu_id = "" || spu_id is null');
170
-//            $query->where('type',17);
171
-            $query->where('is_good',1);
172
-        }
173
-
174
-        $query->when(isset($where['order']),function($query)use($where){
154
+        })->when(isset($where['order']),function($query)use($where){
175 155
             $query->when(in_array($where['order'], ['is_new', 'price_asc', 'price_desc', 'rate', 'sales', 'create_time']), function ($query) use ($where) {
176 156
                 if ($where['order'] == 'price_asc') {
177 157
                     $where['order'] = 'price ASC';

+ 4 - 3
app/common/repositories/system/merchant/MerchantRepository.php

@@ -425,6 +425,7 @@ class MerchantRepository extends BaseRepository
425 425
         $arr=[];
426 426
         foreach ($list["list"] as $v){
427 427
             $k= app()->make(ProductRepository::class)->pvParm($v['product_id']);
428
+            $productMerId = $v['mer_id'] ?? 0;
428 429
 //            $v['special_merchant']= merchantConfig($v['mer_id'], 'special_merchant');
429 430
 
430 431
             log::info("==========yang= {$k['yanglao']} ");
@@ -453,7 +454,7 @@ class MerchantRepository extends BaseRepository
453 454
                 $num_yl = 8000;
454 455
             }
455 456
 
456
-            if($merId == 496){
457
+            if($productMerId == 496){
457 458
 
458 459
                 $v['yanglao'] = bcmul($num_yl, 0.035, 2);
459 460
                 $v['pv'] = bcmul($num_yl, 0.7, 2);
@@ -467,7 +468,7 @@ class MerchantRepository extends BaseRepository
467 468
                     ]
468 469
                 ];
469 470
 
470
-            }else if($merId == 439 || $is_commercetrade){
471
+            }else if($productMerId == 439 || $is_commercetrade){
471 472
                 //精彩生活和商贸区
472 473
                 $jf = $v['price'] - bcmul($v['concession_pri'],0.3, 2) . ' + ' . bcmul($v['concession_pri'],0.3, 2);
473 474
                 $jd = $v['price'] - bcmul($v['concession_pri'],0.35, 2) . ' + ' . bcmul($v['concession_pri'],0.35, 2);
@@ -479,7 +480,7 @@ class MerchantRepository extends BaseRepository
479 480
                     $v['jifen'] = bcmul($v['concession_pri'], 0.35, 2);
480 481
                     $v['gongxian'] = bcmul($v['concession_pri'], 0.35, 2);
481 482
                 }
482
-            }else if($merId == 491){
483
+            }else if($productMerId == 491){
483 484
                 // 获取商品sku
484 485
                 $productSku = Db::name('store_product_attr_value')->where('product_id', $v['product_id'])->order('price asc')->find();
485 486
                 $pv = $productSku['plate_mer_profit']??0.00;

+ 44 - 0
app/controller/api/store/merchant/Merchant.php

@@ -142,6 +142,50 @@ class Merchant extends BaseController
142 142
     }
143 143
 
144 144
     /**
145
+     * 获取商户上架的商品列表
146
+     * @return mixed
147
+     */
148
+    public function getProductList()
149
+    {
150
+        $params = request()->only(['pageNum', 'pageSize', 'mer_id']);
151
+        $merId = $params['mer_id'] ?? 0;
152
+
153
+        [$page, $limit] = $this->getPage();
154
+        $where = request()->only(['keyword']);
155
+        $where['is_gift_bag'] = 0;
156
+        $where['is_used'] = 1;
157
+        $where['product_type'] = 0;
158
+        $where['is_hide'] = 0;
159
+        $result = $this->repository->productList($merId, $where, $page, $limit, $this->userInfo);
160
+        $formatList = [];
161
+        foreach ($result['list'] as $productInfo) {
162
+            $formatList[] = [
163
+                'type' => 0,//京东商品
164
+                'skuId' => '',//itemId 京东官方 已不返回skuId , 使用 联盟商品ID 代替skuId
165
+                'id' => $productInfo['product_id'] ?? '', //id
166
+                'name' => $productInfo['store_name'],//名称
167
+                'thumb' => $productInfo['image'] ?? '',//商品缩略图
168
+
169
+                'pv' => $productInfo['pv'],//PV金额
170
+                'gongxian' => $productInfo['gongxian'],
171
+                'jifen' => $productInfo['jifen'],
172
+                'yanglaojin' => $productInfo['yanglao'],
173
+
174
+                'commission' => $productInfo['concession_pri'],//佣金
175
+                'commission_rate' => null,//佣金比例
176
+                'coupon_money' => [],
177
+                'coupon_link' => '',
178
+                'lowestCouponPrice' => $productInfo['price'],
179
+                'price' => $productInfo['ot_price'], //价格
180
+                'imageList' => $productInfo['slider_image'], //图片合集
181
+                'materialUrl' => ''
182
+            ];
183
+        }
184
+        return app('json')->success(['count' => $result['count'], 'list' => $formatList, 'merId' => $merId]);
185
+    }
186
+
187
+
188
+    /**
145 189
      * 商贸区店铺商品列表
146 190
      * @return mixed
147 191
      * @throws \think\db\exception\DataNotFoundException

+ 1 - 0
route/api.php

@@ -725,6 +725,7 @@ Route::group('api/', function () {
725 725
             //店铺列表
726 726
             Route::get('listindex', 'Merchant/listindex');
727 727
             Route::get('/product/lst/:id', 'Merchant/productList');
728
+            Route::get('/product/getProductList', 'Merchant/getProductList');
728 729
             Route::get('/product/type_lst', 'Merchant/productTypeList');//特殊-根据商户查询商品
729 730
             Route::get('/product/commerce_list', 'Merchant/commerceProductList');//特殊-根据商户查询商品
730 731
             Route::get('/areaProduct/lst', 'Merchant/areaProductList');