|
@@ -122,8 +122,8 @@ class StoreProduct extends BaseModel
|
|
if (is_null($item['cart_num'])) $item['cart_num'] = 0;
|
|
if (is_null($item['cart_num'])) $item['cart_num'] = 0;
|
|
}
|
|
}
|
|
if ($store_id) {
|
|
if ($store_id) {
|
|
- $stockinfo = SystemStoreProductStock::where('product_id', $item['id'])->find();
|
|
+ $stockinfo = SystemStoreProductStock::where('product_id', $item['id'])->where('store_id', $store_id)->find();
|
|
- $item['price'] = $stockinfo ? SystemStoreProductStock::where('product_id', $item['id'])->min('price') : $item['price'];
|
|
+ $item['price'] = $stockinfo ? SystemStoreProductStock::where('product_id', $item['id'])->where('store_id', $store_id)->min('price') : $item['price'];
|
|
}
|
|
}
|
|
});
|
|
});
|
|
$list = count($list) ? $list->toArray() : [];
|
|
$list = count($list) ? $list->toArray() : [];
|
|
@@ -179,7 +179,7 @@ class StoreProduct extends BaseModel
|
|
* @param int $limit
|
|
* @param int $limit
|
|
* @return false|\PDOStatement|string|\think\Collection
|
|
* @return false|\PDOStatement|string|\think\Collection
|
|
*/
|
|
*/
|
|
- public static function getNewProduct($field = '*', $limit = 0, $uid = 0, bool $bool = true)
|
|
+ public static function getNewProduct($field = '*', $limit = 0, $uid = 0, bool $bool = true, $store_id = 0)
|
|
{
|
|
{
|
|
if (!$limit && !$bool) return [];
|
|
if (!$limit && !$bool) return [];
|
|
$model = self::where('is_new', 1)->where('is_del', 0)->where('mer_id', 0)
|
|
$model = self::where('is_new', 1)->where('is_del', 0)->where('mer_id', 0)
|
|
@@ -190,6 +190,10 @@ class StoreProduct extends BaseModel
|
|
$list = count($list) ? $list->toArray() : [];
|
|
$list = count($list) ? $list->toArray() : [];
|
|
if (!empty($list)) {
|
|
if (!empty($list)) {
|
|
foreach ($list as $k => $v) {
|
|
foreach ($list as $k => $v) {
|
|
|
|
+ if ($store_id) {
|
|
|
|
+ $stockinfo = SystemStoreProductStock::where('product_id', $list[$k]['id'])->where('store_id', $store_id)->find();
|
|
|
|
+ $item['price'] = $stockinfo ? SystemStoreProductStock::where('product_id', $list[$k]['id'])->where('store_id', $store_id)->min('price') : $list[$k]['price'];
|
|
|
|
+ }
|
|
$list[$k]['activity'] = self::activity($v['id']);
|
|
$list[$k]['activity'] = self::activity($v['id']);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -202,7 +206,7 @@ class StoreProduct extends BaseModel
|
|
* @param int $limit
|
|
* @param int $limit
|
|
* @return false|\PDOStatement|string|\think\Collection
|
|
* @return false|\PDOStatement|string|\think\Collection
|
|
*/
|
|
*/
|
|
- public static function getHotProduct($field = '*', $limit = 0, $uid = 0)
|
|
+ public static function getHotProduct($field = '*', $limit = 0, $uid = 0, $store_id = 0)
|
|
{
|
|
{
|
|
$model = self::where('is_hot', 1)->where('is_del', 0)->where('mer_id', 0)
|
|
$model = self::where('is_hot', 1)->where('is_del', 0)->where('mer_id', 0)
|
|
->where('stock', '>', 0)->where('is_show', 1)->field($field)
|
|
->where('stock', '>', 0)->where('is_show', 1)->field($field)
|
|
@@ -212,6 +216,10 @@ class StoreProduct extends BaseModel
|
|
$list = count($list) ? $list->toArray() : [];
|
|
$list = count($list) ? $list->toArray() : [];
|
|
if (!empty($list)) {
|
|
if (!empty($list)) {
|
|
foreach ($list as $k => $v) {
|
|
foreach ($list as $k => $v) {
|
|
|
|
+ if ($store_id) {
|
|
|
|
+ $stockinfo = SystemStoreProductStock::where('product_id', $list[$k]['id'])->where('store_id', $store_id)->find();
|
|
|
|
+ $item['price'] = $stockinfo ? SystemStoreProductStock::where('product_id', $list[$k]['id'])->where('store_id', $store_id)->min('price') : $list[$k]['price'];
|
|
|
|
+ }
|
|
$list[$k]['activity'] = self::activity($v['id']);
|
|
$list[$k]['activity'] = self::activity($v['id']);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -246,7 +254,7 @@ class StoreProduct extends BaseModel
|
|
* @param int $limit
|
|
* @param int $limit
|
|
* @return false|\PDOStatement|string|\think\Collection
|
|
* @return false|\PDOStatement|string|\think\Collection
|
|
*/
|
|
*/
|
|
- public static function getBestProduct($field = '*', $limit = 0, $uid = 0, bool $bool = true)
|
|
+ public static function getBestProduct($field = '*', $limit = 0, $uid = 0, bool $bool = true, $store_id = 0)
|
|
{
|
|
{
|
|
if (!$limit && !$bool) return [];
|
|
if (!$limit && !$bool) return [];
|
|
$model = self::where('is_best', 1)->where('is_del', 0)->where('mer_id', 0)
|
|
$model = self::where('is_best', 1)->where('is_del', 0)->where('mer_id', 0)
|
|
@@ -258,6 +266,10 @@ class StoreProduct extends BaseModel
|
|
if (!empty($list)) {
|
|
if (!empty($list)) {
|
|
foreach ($list as $k => $v) {
|
|
foreach ($list as $k => $v) {
|
|
$list[$k]['activity'] = self::activity($v['id']);
|
|
$list[$k]['activity'] = self::activity($v['id']);
|
|
|
|
+ if ($store_id) {
|
|
|
|
+ $stockinfo = SystemStoreProductStock::where('product_id', $list[$k]['id'])->where('store_id', $store_id)->find();
|
|
|
|
+ $item['price'] = $stockinfo ? SystemStoreProductStock::where('product_id', $list[$k]['id'])->where('store_id', $store_id)->min('price') : $list[$k]['price'];
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return self::setLevelPrice($list, $uid);
|
|
return self::setLevelPrice($list, $uid);
|
|
@@ -309,7 +321,7 @@ class StoreProduct extends BaseModel
|
|
* @param int $limit
|
|
* @param int $limit
|
|
* @return false|\PDOStatement|string|\think\Collection
|
|
* @return false|\PDOStatement|string|\think\Collection
|
|
*/
|
|
*/
|
|
- public static function getBenefitProduct($field = '*', $limit = 0)
|
|
+ public static function getBenefitProduct($field = '*', $limit = 0, $store_id = 0)
|
|
{
|
|
{
|
|
$model = self::where('is_benefit', 1)
|
|
$model = self::where('is_benefit', 1)
|
|
->where('is_del', 0)->where('mer_id', 0)->where('stock', '>', 0)
|
|
->where('is_del', 0)->where('mer_id', 0)->where('stock', '>', 0)
|
|
@@ -319,6 +331,10 @@ class StoreProduct extends BaseModel
|
|
$data = $model->select();
|
|
$data = $model->select();
|
|
if (count($data) > 0) {
|
|
if (count($data) > 0) {
|
|
foreach ($data as $k => $v) {
|
|
foreach ($data as $k => $v) {
|
|
|
|
+ if ($store_id) {
|
|
|
|
+ $stockinfo = SystemStoreProductStock::where('product_id', $data[$k]['id'])->where('store_id', $store_id)->find();
|
|
|
|
+ $data['price'] = $stockinfo ? SystemStoreProductStock::where('product_id', $data[$k]['id'])->where('store_id', $store_id)->min('price') : $data[$k]['price'];
|
|
|
|
+ }
|
|
$data[$k]['activity'] = self::activity($v['id']);
|
|
$data[$k]['activity'] = self::activity($v['id']);
|
|
}
|
|
}
|
|
}
|
|
}
|