|
@@ -8,6 +8,7 @@
|
|
|
namespace app\models\store;
|
|
|
|
|
|
use app\admin\model\store\StoreProductAttrValue as StoreProductAttrValueModel;
|
|
|
+use app\admin\model\system\SystemStoreProductStock;
|
|
|
use app\models\system\SystemUserLevel;
|
|
|
use app\models\user\UserLevel;
|
|
|
use crmeb\basic\BaseModel;
|
|
@@ -82,7 +83,7 @@ class StoreProduct extends BaseModel
|
|
|
return self::where('is_del', 0)->where('is_show', 1)->where('mer_id', 0);
|
|
|
}
|
|
|
|
|
|
- public static function getProductList($data, $uid)
|
|
|
+ public static function getProductList($data, $uid, $store_id = 0)
|
|
|
{
|
|
|
$sId = $data['sid'];
|
|
|
$cId = $data['cid'];
|
|
@@ -113,13 +114,17 @@ class StoreProduct extends BaseModel
|
|
|
if ($salesOrder) $baseOrder = $salesOrder == 'desc' ? 'sales DESC' : 'sales ASC';
|
|
|
if ($baseOrder) $baseOrder .= ', ';
|
|
|
$model->order($baseOrder . 'sort DESC, add_time DESC');
|
|
|
- $list = $model->page((int)$page, (int)$limit)->field('id,store_name,cate_id,image,IFNULL(sales,0) + IFNULL(ficti,0) as sales,price,stock')->select()->each(function ($item) use ($uid, $type) {
|
|
|
+ $list = $model->page((int)$page, (int)$limit)->field('id,store_name,cate_id,image,IFNULL(sales,0) + IFNULL(ficti,0) as sales,price,stock')->select()->each(function ($item) use ($uid, $type, $store_id) {
|
|
|
if ($type) {
|
|
|
$item['is_att'] = StoreProductAttrValueModel::where('product_id', $item['id'])->count() ? true : false;
|
|
|
if ($uid) $item['cart_num'] = StoreCart::where('is_pay', 0)->where('is_del', 0)->where('is_new', 0)->where('type', 'product')->where('product_id', $item['id'])->where('uid', $uid)->value('cart_num');
|
|
|
else $item['cart_num'] = 0;
|
|
|
if (is_null($item['cart_num'])) $item['cart_num'] = 0;
|
|
|
}
|
|
|
+ if ($store_id) {
|
|
|
+ $stockinfo = SystemStoreProductStock::where('product_id', $item['id'])->find();
|
|
|
+ $item['price'] = $stockinfo ? SystemStoreProductStock::where('product_id', $item['id'])->min('price') : $item['price'];
|
|
|
+ }
|
|
|
});
|
|
|
$list = count($list) ? $list->toArray() : [];
|
|
|
if (!empty($list)) {
|
|
@@ -584,7 +589,7 @@ class StoreProduct extends BaseModel
|
|
|
$activity = explode(',', $activity);
|
|
|
$activityId = [];
|
|
|
$time = 0;
|
|
|
- $seckillId = StoreSeckill::where('is_del', 0)->where('status', 1)->where('start_time', '<=', time())->where('stop_time', '>=', time()-86400)->where('product_id', $id)->field('id,time_id')->select();
|
|
|
+ $seckillId = StoreSeckill::where('is_del', 0)->where('status', 1)->where('start_time', '<=', time())->where('stop_time', '>=', time() - 86400)->where('product_id', $id)->field('id,time_id')->select();
|
|
|
if ($seckillId) {
|
|
|
foreach ($seckillId as $v) {
|
|
|
$timeInfo = GroupDataService::getDataNumber((int)$v['time_id']);
|
|
@@ -598,7 +603,7 @@ class StoreProduct extends BaseModel
|
|
|
}
|
|
|
$bargainId = StoreBargain::where('is_del', 0)->where('status', 1)->where('start_time', '<=', time())->where('stop_time', '>=', time())->where('product_id', $id)->value('id');
|
|
|
if ($bargainId) $activityId[2] = $bargainId;
|
|
|
- $combinationId = StoreCombination::where('is_del', 0)->where('is_show',1)->where('start_time', '<=', time())->where('stop_time', '>=', time())->where('product_id', $id)->value('id');
|
|
|
+ $combinationId = StoreCombination::where('is_del', 0)->where('is_show', 1)->where('start_time', '<=', time())->where('stop_time', '>=', time())->where('product_id', $id)->value('id');
|
|
|
if ($combinationId) $activityId[3] = $combinationId;
|
|
|
$data = [];
|
|
|
foreach ($activity as $k => $v) {
|