1
This commit is contained in:
@@ -12,6 +12,7 @@ use App\Model\Hospital;
|
||||
use App\Model\HospitalDepartmentCustom;
|
||||
use App\Model\OperationManual;
|
||||
use App\Model\Product;
|
||||
use Hyperf\Redis\Redis;
|
||||
|
||||
/**
|
||||
* 基础数据服务类
|
||||
@@ -210,6 +211,8 @@ class BasicDataService extends BaseService
|
||||
*/
|
||||
public function getProductSearch(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
$product_keyword = $this->request->input('product_keyword');
|
||||
|
||||
$fields = [
|
||||
@@ -234,6 +237,15 @@ class BasicDataService extends BaseService
|
||||
return success();
|
||||
}
|
||||
|
||||
// 获取购物车缓存数据
|
||||
$redis = $this->container->get(Redis::class);
|
||||
|
||||
$redis_key = "shopping_cart" . $user_info['client_user_id'];
|
||||
$shopping_cart = $redis->get($redis_key);
|
||||
if (!empty($shopping_cart)){
|
||||
$shopping_cart = json_decode($shopping_cart,true);
|
||||
}
|
||||
|
||||
foreach ($product as &$item) {
|
||||
$item['product_cover_img'] = addAliyunOssWebsite($item['product_cover_img']);
|
||||
|
||||
@@ -244,6 +256,16 @@ class BasicDataService extends BaseService
|
||||
}
|
||||
|
||||
unset($item['ProductPlatformAmount']);
|
||||
|
||||
// 处理购物车商品数据
|
||||
$item['shopping_cart_num'] = 0;
|
||||
if (!empty($shopping_cart)){
|
||||
foreach ($shopping_cart as $value){
|
||||
if ($item['product_id'] == $value['product_id']){
|
||||
$item['shopping_cart_num'] = $value['shopping_cart_num'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return success($product->toArray());
|
||||
|
||||
Reference in New Issue
Block a user