新增搜索商品库存字段返回
This commit is contained in:
@@ -214,6 +214,7 @@ class BasicDataService extends BaseService
|
||||
|
||||
$fields = [
|
||||
'product_id',
|
||||
'product_platform_id',
|
||||
'product_name',
|
||||
'product_price',
|
||||
'product_cover_img',
|
||||
@@ -237,6 +238,12 @@ class BasicDataService extends BaseService
|
||||
$item['product_cover_img'] = addAliyunOssWebsite($item['product_cover_img']);
|
||||
|
||||
$item['product_name'] = $item['product_name'] . ' ' . $item['product_spec'];
|
||||
$item['stock'] = 0;
|
||||
if (!empty($item['ProductPlatformAmount'])){
|
||||
$item['stock'] = $item['ProductPlatformAmount']['stock'];
|
||||
}
|
||||
|
||||
unset($item['ProductPlatformAmount']);
|
||||
}
|
||||
|
||||
return success($product->toArray());
|
||||
|
||||
@@ -397,6 +397,9 @@ class LoginService extends BaseService
|
||||
$Jwt = new Jwt();
|
||||
$token = $Jwt->encode($token_user_data);
|
||||
|
||||
// 登录成功,删除验证码
|
||||
// $redis->del("login_code" . $phone);
|
||||
|
||||
// 组合返回数据
|
||||
$data = array();
|
||||
$data['token'] = $token;
|
||||
|
||||
@@ -6,11 +6,15 @@ use App\Constants\HttpEnumCode;
|
||||
use App\Model\Coupon;
|
||||
use App\Model\OrderInquiry;
|
||||
use App\Model\PatientHistoryInquiry;
|
||||
use App\Model\Product;
|
||||
use App\Model\User;
|
||||
use App\Model\UserCoupon;
|
||||
use App\Model\UserPatient;
|
||||
use App\Utils\Mask;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use Hyperf\Redis\Redis;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* 患者
|
||||
@@ -197,6 +201,57 @@ class UserPatientService extends BaseService
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取购物车药品数据
|
||||
* @return array
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function getShoppingCart(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
$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)){
|
||||
// 购物车为空
|
||||
return success();
|
||||
}
|
||||
|
||||
$shopping_cart = json_decode($shopping_cart,true);
|
||||
|
||||
return success($shopping_cart);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加购物车药品数据
|
||||
* @return array
|
||||
*/
|
||||
public function addShoppingCart(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
$product_id = $this->request->route('product_id');
|
||||
|
||||
// $redis = $this->container->get(Redis::class);
|
||||
|
||||
// 验证商品数据
|
||||
$params =array();
|
||||
$params['product_id'] = $product_id;
|
||||
$product = Product::getOne($params);
|
||||
if (empty($product)){
|
||||
return fail();
|
||||
}
|
||||
|
||||
// 获取商品库存
|
||||
|
||||
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户可领取优惠卷
|
||||
* @param string|int $user_id
|
||||
|
||||
Reference in New Issue
Block a user