Browse Source

会员升级

Kirin 7 months ago
parent
commit
b0e3e34d1c

+ 41 - 40
app/controller/api/v1/store/StoreProductController.php

@@ -56,6 +56,7 @@ class StoreProductController
             ['store_id', 0, '', 'relation_id'],
             ['delivery_type', ''],
             [['collate_code_id', 'd'], 0], //拼单ID 、桌码ID
+            ['award', -1], //拼单ID 、桌码ID
         ]);
         if ($where['selectId'] && (!$where['sid'] || !$where['cid'])) {
             if ($services->value(['id' => $where['selectId']], 'pid')) {
@@ -64,7 +65,7 @@ class StoreProductController
                 $where['cid'] = $where['selectId'];
             }
         }
-		$where['ids'] = stringToArray($where['ids']);
+        $where['ids'] = stringToArray($where['ids']);
         if (!$where['ids']) {
             unset($where['ids']);
         }
@@ -77,20 +78,20 @@ class StoreProductController
             $field = ['image'];
         }
 
-		if ($where['relation_id']) {//获取定位门店商品
-			if ($where['delivery_type'] == 2) {// 获取自提商品
-				//验证平台自提开启,门店自提是否开启
-				if(!sys_config('store_self_mention', 1) || !$storeServices->value(['id' => $where['relation_id'], 'is_show' => 1, 'is_del' => 0], 'is_store')) {
-					return app('json')->success([]);
-				}
-			}
-			$where['type'] = 1;
-			$where['show_type'] = [0, 1];
-			$list = $this->services->getGoodsList($where, (int)$request->uid());
-        	return app('json')->successful(get_thumb_water($list, $type, $field));
-		} else {
-			return app('json')->success([]);
-		}
+        if ($where['relation_id']) {//获取定位门店商品
+            if ($where['delivery_type'] == 2) {// 获取自提商品
+                //验证平台自提开启,门店自提是否开启
+                if (!sys_config('store_self_mention', 1) || !$storeServices->value(['id' => $where['relation_id'], 'is_show' => 1, 'is_del' => 0], 'is_store')) {
+                    return app('json')->success([]);
+                }
+            }
+            $where['type'] = 1;
+            $where['show_type'] = [0, 1];
+            $list = $this->services->getGoodsList($where, (int)$request->uid());
+            return app('json')->successful(get_thumb_water($list, $type, $field));
+        } else {
+            return app('json')->success([]);
+        }
     }
 
     /**
@@ -101,31 +102,31 @@ class StoreProductController
      */
     public function brand(Request $request, StoreProductCategoryServices $services)
     {
-		$where = $request->getMore([
-			[['sid', 'd'], 0],
-			[['cid', 'd'], 0],
-			['store_id', 0, '', 'relation_id'],
-			['selectId', '']
-		]);
-		if ($where['selectId'] && (!$where['sid'] || !$where['cid'])) {
-			if ($services->value(['id' => $where['selectId']], 'pid')) {
-				$where['sid'] = $where['selectId'];
-			} else {
-				$where['cid'] = $where['selectId'];
-			}
-		}
-		$cate_id = [];
-		if ($where['sid']) {
-			$cate_id = [$where['sid']];
-		} elseif ($where['cid']) {
-			$cate_id = array_merge([$where['cid']], $services->getColumn(['pid' => $where['cid'], 'is_show' => 1], 'id'));
-		}
-		if ($where['relation_id']) {//获取定位门店商品
-			$where['type'] = 1;
-			return app('json')->successful($this->services->getBrandList(['cate_id' => $cate_id]));
-		} else {
-			return app('json')->success([]);
-		}
+        $where = $request->getMore([
+            [['sid', 'd'], 0],
+            [['cid', 'd'], 0],
+            ['store_id', 0, '', 'relation_id'],
+            ['selectId', '']
+        ]);
+        if ($where['selectId'] && (!$where['sid'] || !$where['cid'])) {
+            if ($services->value(['id' => $where['selectId']], 'pid')) {
+                $where['sid'] = $where['selectId'];
+            } else {
+                $where['cid'] = $where['selectId'];
+            }
+        }
+        $cate_id = [];
+        if ($where['sid']) {
+            $cate_id = [$where['sid']];
+        } elseif ($where['cid']) {
+            $cate_id = array_merge([$where['cid']], $services->getColumn(['pid' => $where['cid'], 'is_show' => 1], 'id'));
+        }
+        if ($where['relation_id']) {//获取定位门店商品
+            $where['type'] = 1;
+            return app('json')->successful($this->services->getBrandList(['cate_id' => $cate_id]));
+        } else {
+            return app('json')->success([]);
+        }
 
     }
 

+ 27 - 24
app/dao/product/product/StoreProductDao.php

@@ -106,16 +106,16 @@ class StoreProductDao extends BaseDao
             })->when(isset($where['ids']) && $where['ids'], function ($query) use ($where) {
                 if (!isset($where['type'])) $query->where('id', 'in', $where['ids']);
             })->when(isset($where['not_ids']) && $where['not_ids'], function ($query) use ($where) {
-				$query->whereNotIn('id', $where['not_ids']);
-			})->when(isset($where['pids']) && $where['pids'], function ($query) use ($where) {
-				if ((isset($where['priceOrder']) && $where['priceOrder'] != '') || (isset($where['salesOrder']) && $where['salesOrder'] != '')) {
-					$query->whereIn('pid', $where['pids']);
-				} else {
-					$query->whereIn('pid', $where['pids'])->orderField('pid', $where['pids'], 'asc');
-				}
-			})->when(isset($where['not_pids']) && $where['not_pids'], function ($query) use ($where) {
-				$query->whereNotIn('pid', $where['not_pids']);
-			})->count();
+                $query->whereNotIn('id', $where['not_ids']);
+            })->when(isset($where['pids']) && $where['pids'], function ($query) use ($where) {
+                if ((isset($where['priceOrder']) && $where['priceOrder'] != '') || (isset($where['salesOrder']) && $where['salesOrder'] != '')) {
+                    $query->whereIn('pid', $where['pids']);
+                } else {
+                    $query->whereIn('pid', $where['pids'])->orderField('pid', $where['pids'], 'asc');
+                }
+            })->when(isset($where['not_pids']) && $where['not_pids'], function ($query) use ($where) {
+                $query->whereNotIn('pid', $where['not_pids']);
+            })->count();
     }
 
     /**
@@ -244,6 +244,9 @@ class StoreProductDao extends BaseDao
             if (is_array($where['use_min_price']) && count($where['use_min_price']) == 2) {
                 $query->where('price', $where['use_min_price'][0] ?? '=', $where['use_min_price'][1] ?? 0);
             }
+        })->when(isset($where['award']) && $where['award'] >= 0, function ($query) use ($where) {
+            if ($where['award']) $query->where('award_price', '>', 0);
+            if ($where['award']) $query->where('award_price', 0);
         })->when(!$page && $limit, function ($query) use ($limit) {
             $query->limit($limit);
         })->field($field)->select()->toArray();
@@ -278,19 +281,19 @@ class StoreProductDao extends BaseDao
         return $this->getModel()->whereIn('id', $ids)->field($field)->select()->toArray();
     }
 
-	/**
-	 * 获取推荐商品
-	 * @param array $where
-	 * @param array $field
-	 * @param int $num
-	 * @param int $page
-	 * @param int $limit
-	 * @param array $with
-	 * @return array
-	 * @throws \think\db\exception\DataNotFoundException
-	 * @throws \think\db\exception\DbException
-	 * @throws \think\db\exception\ModelNotFoundException
-	 */
+    /**
+     * 获取推荐商品
+     * @param array $where
+     * @param array $field
+     * @param int $num
+     * @param int $page
+     * @param int $limit
+     * @param array $with
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
     public function getRecommendProduct(array $where, array $field = ['*'], int $num = 0, int $page = 0, int $limit = 0, array $with = ['couponId', 'star'])
     {
         return $this->search($where)->field($field)
@@ -317,7 +320,7 @@ class StoreProductDao extends BaseDao
      */
     public function getProductCartList(array $where, int $page, int $limit, array $field = ['*'])
     {
-		$where['is_verify'] = 1;
+        $where['is_verify'] = 1;
         $where['is_show'] = 1;
         $where['is_del'] = 0;
         return $this->search($where)->when($page, function ($query) use ($page, $limit) {