新增搜索商品库存字段返回
This commit is contained in:
@@ -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