新增搜索商品库存字段返回
This commit is contained in:
parent
9dd6116f44
commit
983f4d8909
@ -205,8 +205,6 @@ class PatientFamilyController extends AbstractController
|
|||||||
/**
|
/**
|
||||||
* 获取家庭成员用药记录列表
|
* 获取家庭成员用药记录列表
|
||||||
* @return ResponseInterface
|
* @return ResponseInterface
|
||||||
* @throws ContainerExceptionInterface
|
|
||||||
* @throws NotFoundExceptionInterface
|
|
||||||
*/
|
*/
|
||||||
public function getFamilyProductRecord(): ResponseInterface
|
public function getFamilyProductRecord(): ResponseInterface
|
||||||
{
|
{
|
||||||
|
|||||||
@ -64,6 +64,33 @@ class UserPatientController extends AbstractController
|
|||||||
return $this->response->json($data);
|
return $this->response->json($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// public function
|
/**
|
||||||
|
* 获取购物车药品数据
|
||||||
|
* @return ResponseInterface
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
*/
|
||||||
|
public function getShoppingCart(): ResponseInterface
|
||||||
|
{
|
||||||
|
$UserPatientService = new UserPatientService();
|
||||||
|
$data = $UserPatientService->getShoppingCart();
|
||||||
|
return $this->response->json($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加购物车药品数据
|
||||||
|
* @return ResponseInterface
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
*/
|
||||||
|
public function addShoppingCart(): ResponseInterface
|
||||||
|
{
|
||||||
|
$request = $this->container->get(UserPatientRequest::class);
|
||||||
|
$request->scene('addShoppingCart')->validateResolved();
|
||||||
|
|
||||||
|
$UserPatientService = new UserPatientService();
|
||||||
|
$data = $UserPatientService->addShoppingCart();
|
||||||
|
return $this->response->json($data);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -103,7 +103,10 @@ class Product extends Model
|
|||||||
*/
|
*/
|
||||||
public static function getSearchKeywordList(array $params = [],string $keyword = '',array $fields = ['*']): Collection|array
|
public static function getSearchKeywordList(array $params = [],string $keyword = '',array $fields = ['*']): Collection|array
|
||||||
{
|
{
|
||||||
return self::when($keyword, function ($query, $keyword) {
|
return self::with([
|
||||||
|
'ProductPlatformAmount:amount_id,product_platform_id,stock'
|
||||||
|
])
|
||||||
|
->when($keyword, function ($query, $keyword) {
|
||||||
$query->where(function ($query) use ($keyword) {
|
$query->where(function ($query) use ($keyword) {
|
||||||
$query->orwhere("product_name", 'like', '%' . $keyword . '%');
|
$query->orwhere("product_name", 'like', '%' . $keyword . '%');
|
||||||
$query->orwhere("common_name", 'like', '%' . $keyword . '%');
|
$query->orwhere("common_name", 'like', '%' . $keyword . '%');
|
||||||
|
|||||||
@ -13,6 +13,9 @@ class UserPatientRequest extends FormRequest
|
|||||||
'getPatientCouponlist' => [ // 获取患者优惠卷列表
|
'getPatientCouponlist' => [ // 获取患者优惠卷列表
|
||||||
'user_coupon_status',
|
'user_coupon_status',
|
||||||
],
|
],
|
||||||
|
'addShoppingCart' => [ // 添加购物车药品数据
|
||||||
|
'product_id',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -30,6 +33,7 @@ class UserPatientRequest extends FormRequest
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'user_coupon_status' => 'required|integer|min:0|max:2',
|
'user_coupon_status' => 'required|integer|min:0|max:2',
|
||||||
|
'product_id' => 'required',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,6 +47,7 @@ class UserPatientRequest extends FormRequest
|
|||||||
'user_coupon_status.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
'user_coupon_status.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
'user_coupon_status.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
'user_coupon_status.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
'user_coupon_status.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
'user_coupon_status.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
|
'product_id.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -214,6 +214,7 @@ class BasicDataService extends BaseService
|
|||||||
|
|
||||||
$fields = [
|
$fields = [
|
||||||
'product_id',
|
'product_id',
|
||||||
|
'product_platform_id',
|
||||||
'product_name',
|
'product_name',
|
||||||
'product_price',
|
'product_price',
|
||||||
'product_cover_img',
|
'product_cover_img',
|
||||||
@ -237,6 +238,12 @@ class BasicDataService extends BaseService
|
|||||||
$item['product_cover_img'] = addAliyunOssWebsite($item['product_cover_img']);
|
$item['product_cover_img'] = addAliyunOssWebsite($item['product_cover_img']);
|
||||||
|
|
||||||
$item['product_name'] = $item['product_name'] . ' ' . $item['product_spec'];
|
$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());
|
return success($product->toArray());
|
||||||
|
|||||||
@ -397,6 +397,9 @@ class LoginService extends BaseService
|
|||||||
$Jwt = new Jwt();
|
$Jwt = new Jwt();
|
||||||
$token = $Jwt->encode($token_user_data);
|
$token = $Jwt->encode($token_user_data);
|
||||||
|
|
||||||
|
// 登录成功,删除验证码
|
||||||
|
// $redis->del("login_code" . $phone);
|
||||||
|
|
||||||
// 组合返回数据
|
// 组合返回数据
|
||||||
$data = array();
|
$data = array();
|
||||||
$data['token'] = $token;
|
$data['token'] = $token;
|
||||||
|
|||||||
@ -6,11 +6,15 @@ use App\Constants\HttpEnumCode;
|
|||||||
use App\Model\Coupon;
|
use App\Model\Coupon;
|
||||||
use App\Model\OrderInquiry;
|
use App\Model\OrderInquiry;
|
||||||
use App\Model\PatientHistoryInquiry;
|
use App\Model\PatientHistoryInquiry;
|
||||||
|
use App\Model\Product;
|
||||||
use App\Model\User;
|
use App\Model\User;
|
||||||
use App\Model\UserCoupon;
|
use App\Model\UserCoupon;
|
||||||
use App\Model\UserPatient;
|
use App\Model\UserPatient;
|
||||||
use App\Utils\Mask;
|
use App\Utils\Mask;
|
||||||
use Hyperf\DbConnection\Db;
|
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 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
|
* @param string|int $user_id
|
||||||
|
|||||||
@ -310,17 +310,15 @@ Router::addGroup('/patient', function () {
|
|||||||
Router::addGroup('/product', function () {
|
Router::addGroup('/product', function () {
|
||||||
// 购物车
|
// 购物车
|
||||||
Router::addGroup('/shopping', function () {
|
Router::addGroup('/shopping', function () {
|
||||||
// 获取购物车
|
// 获取购物车药品数据
|
||||||
Router::get('/cart', [UserPatientController::class, 'addShoppingCart']);
|
Router::get('/cart', [UserPatientController::class, 'getShoppingCart']);
|
||||||
|
|
||||||
// 添加购物车
|
// 添加购物车药品数据
|
||||||
Router::post('/cart', [UserPatientController::class, 'addShoppingCart']);
|
Router::post('/cart', [UserPatientController::class, 'addShoppingCart']);
|
||||||
|
|
||||||
// 修改购物车
|
// 修改购物车药品数据
|
||||||
Router::put('/cart', [UserPatientController::class, 'putShoppingCart']);
|
Router::put('/cart', [UserPatientController::class, 'putShoppingCart']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// 订单
|
// 订单
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user