新增药师微信登录
This commit is contained in:
parent
0e9f273c4f
commit
229f875a84
@ -87,6 +87,72 @@ class UserController extends AbstractController
|
|||||||
return $this->response->json($data);
|
return $this->response->json($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户收获地址列表
|
||||||
|
* @return ResponseInterface
|
||||||
|
*/
|
||||||
|
public function getUserAddress(): ResponseInterface
|
||||||
|
{
|
||||||
|
$UserService = new UserService();
|
||||||
|
$data = $UserService->getUserAddress();
|
||||||
|
return $this->response->json($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户收获地址详情
|
||||||
|
* @return ResponseInterface
|
||||||
|
*/
|
||||||
|
public function getUserAddressInfo(): ResponseInterface
|
||||||
|
{
|
||||||
|
$UserService = new UserService();
|
||||||
|
$data = $UserService->getUserAddressInfo();
|
||||||
|
return $this->response->json($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加用户收获地址列表
|
||||||
|
* @return ResponseInterface
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
*/
|
||||||
|
public function addUserAddress(): ResponseInterface
|
||||||
|
{
|
||||||
|
$request = $this->container->get(UserRequest::class);
|
||||||
|
$request->scene('addUserAddress')->validateResolved();
|
||||||
|
|
||||||
|
$UserService = new UserService();
|
||||||
|
$data = $UserService->addUserAddress();
|
||||||
|
return $this->response->json($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户收获地址列表
|
||||||
|
* @return ResponseInterface
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
*/
|
||||||
|
public function putUserAddress(): ResponseInterface
|
||||||
|
{
|
||||||
|
$request = $this->container->get(UserRequest::class);
|
||||||
|
$request->scene('putUserAddress')->validateResolved();
|
||||||
|
|
||||||
|
$UserService = new UserService();
|
||||||
|
$data = $UserService->putUserAddress();
|
||||||
|
return $this->response->json($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除用户收获地址列表
|
||||||
|
* @return ResponseInterface
|
||||||
|
*/
|
||||||
|
public function deleteUserAddress(): ResponseInterface
|
||||||
|
{
|
||||||
|
$UserService = new UserService();
|
||||||
|
$data = $UserService->deleteUserAddress();
|
||||||
|
return $this->response->json($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 支付测试
|
// 支付测试
|
||||||
public function testpay(){
|
public function testpay(){
|
||||||
// 发起支付
|
// 发起支付
|
||||||
|
|||||||
@ -90,4 +90,24 @@ class UserShipAddress extends Model
|
|||||||
return self::where($params)->count();
|
return self::where($params)->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增
|
||||||
|
* @param array $data
|
||||||
|
* @return \Hyperf\Database\Model\Model|UserShipAddress
|
||||||
|
*/
|
||||||
|
public static function addUserShipAddress(array $data): \Hyperf\Database\Model\Model|UserShipAddress
|
||||||
|
{
|
||||||
|
return self::create($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改
|
||||||
|
* @param array $params
|
||||||
|
* @param array $data
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public static function edit(array $params = [], array $data = []): int
|
||||||
|
{
|
||||||
|
return self::where($params)->update($data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,6 +16,17 @@ class UserRequest extends FormRequest
|
|||||||
'putUserName' => [ // 修改用户名
|
'putUserName' => [ // 修改用户名
|
||||||
'user_name',
|
'user_name',
|
||||||
],
|
],
|
||||||
|
'addUserAddress' => [ // 添加用户收获地址列表
|
||||||
|
'province_id',
|
||||||
|
'city_id',
|
||||||
|
'county_id',
|
||||||
|
'address',
|
||||||
|
'consignee_name',
|
||||||
|
'consignee_tel',
|
||||||
|
'consignee_zip_code',
|
||||||
|
'is_default',
|
||||||
|
'tag',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,6 +45,15 @@ class UserRequest extends FormRequest
|
|||||||
return [
|
return [
|
||||||
'avatar' => 'required|url',
|
'avatar' => 'required|url',
|
||||||
'user_name' => 'required',
|
'user_name' => 'required',
|
||||||
|
|
||||||
|
'province_id' => 'required_with:city_id,county_id',
|
||||||
|
'city_id' => 'required_with:county_id',
|
||||||
|
'county_id' => 'required',
|
||||||
|
'address' => 'required',
|
||||||
|
'consignee_name' => 'required',
|
||||||
|
'consignee_tel' => 'required',
|
||||||
|
'is_default' => ['required','numeric','min:0','max:1'],
|
||||||
|
'tag' => ['required','numeric','min:1','max:3'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,6 +66,21 @@ class UserRequest extends FormRequest
|
|||||||
'avatar.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
'avatar.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
'avatar.url' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
'avatar.url' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
'user_name.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
'user_name.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
|
|
||||||
|
'province_id.required_with' => "请选择省份",
|
||||||
|
'city_id.required_with' => "请选择城市",
|
||||||
|
'county_id.required' => "请选择区县",
|
||||||
|
'address.required' => "请输入详细地址",
|
||||||
|
'consignee_name.required' => "请输入姓名",
|
||||||
|
'consignee_tel.required' => "请输入电话",
|
||||||
|
'is_default.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
|
'is_default.numeric' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
|
'is_default.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
|
'is_default.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
|
'tag.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
|
'tag.numeric' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
|
'tag.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
|
'tag.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,9 +9,11 @@ use App\Model\User as UserModel;
|
|||||||
use App\Model\UserDoctor;
|
use App\Model\UserDoctor;
|
||||||
use App\Model\UserDoctorInfo;
|
use App\Model\UserDoctorInfo;
|
||||||
use App\Model\UserPatient;
|
use App\Model\UserPatient;
|
||||||
|
use App\Model\UserShipAddress;
|
||||||
use App\Utils\PcreMatch;
|
use App\Utils\PcreMatch;
|
||||||
use Extend\TencentIm\Profile;
|
use Extend\TencentIm\Profile;
|
||||||
use Extend\Wechat\Wechat;
|
use Extend\Wechat\Wechat;
|
||||||
|
use GuzzleHttp\Exception\GuzzleException;
|
||||||
use Hyperf\Amqp\Result;
|
use Hyperf\Amqp\Result;
|
||||||
use Hyperf\DbConnection\Db;
|
use Hyperf\DbConnection\Db;
|
||||||
use Hyperf\Redis\Redis;
|
use Hyperf\Redis\Redis;
|
||||||
@ -74,6 +76,7 @@ class UserService extends BaseService
|
|||||||
/**
|
/**
|
||||||
* 修改用户头像
|
* 修改用户头像
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws GuzzleException
|
||||||
*/
|
*/
|
||||||
public function putUserAvatar(): array
|
public function putUserAvatar(): array
|
||||||
{
|
{
|
||||||
@ -236,7 +239,8 @@ class UserService extends BaseService
|
|||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
public function putLoginout(){
|
public function putLoginout(): array
|
||||||
|
{
|
||||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||||
|
|
||||||
// 获取用户信息
|
// 获取用户信息
|
||||||
@ -269,6 +273,90 @@ class UserService extends BaseService
|
|||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户收获地址列表
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getUserAddress(): array
|
||||||
|
{
|
||||||
|
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||||
|
|
||||||
|
$params = array();
|
||||||
|
$params['user_id'] = $user_info['user_id'];
|
||||||
|
$user_ship_address = UserShipAddress::getList($params);
|
||||||
|
if (empty($user_ship_address)){
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
|
||||||
|
return success($user_ship_address->toArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户收获地址详情
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getUserAddressInfo(): array
|
||||||
|
{
|
||||||
|
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||||
|
|
||||||
|
$address_id = $this->request->route('address_id');
|
||||||
|
|
||||||
|
$params = array();
|
||||||
|
$params['address_id'] = $address_id;
|
||||||
|
$params['user_id'] = $user_info['user_id'];
|
||||||
|
$user_ship_address = UserShipAddress::getOne($params);
|
||||||
|
if (empty($user_ship_address)){
|
||||||
|
return fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return success($user_ship_address->toArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加用户收获地址列表
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function addUserAddress(): array
|
||||||
|
{
|
||||||
|
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||||
|
|
||||||
|
$request_params = $this->request->all();
|
||||||
|
|
||||||
|
$areaService = new AreaService();
|
||||||
|
$req = $areaService->checkAreaById($request_params['province_id'],$request_params['city_id'],$request_params['county_id']);
|
||||||
|
if(empty($req)){
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR,"地区选择错误");
|
||||||
|
}
|
||||||
|
|
||||||
|
$area = $areaService->getAreaById($request_params['province_id'],$request_params['city_id'],$request_params['county_id']);
|
||||||
|
|
||||||
|
if ($request_params['is_default'] == 1){
|
||||||
|
// 获取默认地址
|
||||||
|
$params = array();
|
||||||
|
$params['user_id'] = $user_info['user_id'];
|
||||||
|
$params['is_default'] = $request_params['is_default'];
|
||||||
|
$user_ship_address = UserShipAddress::getOne($params);
|
||||||
|
if (!empty($user_ship_address)){
|
||||||
|
// 存在默认
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取默认地址
|
||||||
|
$params = array();
|
||||||
|
$params['user_id'] = $user_info['user_id'];
|
||||||
|
$params['is_default'] = $request_params['is_default'];
|
||||||
|
$user_ship_address = UserShipAddress::getOne($params);
|
||||||
|
if (empty($user_ship_address)){
|
||||||
|
// 不存在默认
|
||||||
|
}else{
|
||||||
|
// 存在默认
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过user_id获取用户openid
|
* 通过user_id获取用户openid
|
||||||
* @param string|int $user_id
|
* @param string|int $user_id
|
||||||
|
|||||||
@ -46,6 +46,10 @@ return [
|
|||||||
"product_pay_notify_url" => env('PATIENT_WECHAT_PRODUCT_PAY_NOTIFY_URL', 'callback/wxpay/product/success'),
|
"product_pay_notify_url" => env('PATIENT_WECHAT_PRODUCT_PAY_NOTIFY_URL', 'callback/wxpay/product/success'),
|
||||||
"product_refund_notify_url" => env('PATIENT_WECHAT_PRODUCT_REFUND_NOTIFY_URL', 'callback/wxpay/product/refund'),
|
"product_refund_notify_url" => env('PATIENT_WECHAT_PRODUCT_REFUND_NOTIFY_URL', 'callback/wxpay/product/refund'),
|
||||||
],
|
],
|
||||||
|
"pharmacist" => [
|
||||||
|
"app_id" => env('DOCTOR_WECHAT_APP_ID', 'wxc83296720404aa7b'),
|
||||||
|
"secret" => env('DOCTOR_WECHAT_APP_SECRET', '817665d3763637fe66d56548f8484622'),
|
||||||
|
],
|
||||||
"pay" => [
|
"pay" => [
|
||||||
"mch_id" => env('PATIENT_WECHAT_MCH_ID', '1636644248'),
|
"mch_id" => env('PATIENT_WECHAT_MCH_ID', '1636644248'),
|
||||||
"v3_api_secret" => env('PATIENT_WECHAT_APIv3_SECRET', 'gdxz292sjSOadN3m2pCda03NfCsmNadY'),
|
"v3_api_secret" => env('PATIENT_WECHAT_APIv3_SECRET', 'gdxz292sjSOadN3m2pCda03NfCsmNadY'),
|
||||||
|
|||||||
@ -524,17 +524,20 @@ Router::get('/testpay', [UserController::class, 'testpay']);
|
|||||||
|
|
||||||
// 地址管理
|
// 地址管理
|
||||||
Router::addGroup('/address', function () {
|
Router::addGroup('/address', function () {
|
||||||
// 获取地址列表
|
// 获取用户收获地址列表
|
||||||
Router::get('', [UserController::class, 'putUserAvatar']);
|
Router::get('', [UserController::class, 'getUserAddress']);
|
||||||
|
|
||||||
// 添加地址
|
// 获取用户收获地址详情
|
||||||
Router::post('', [CallBackController::class, 'imCallBack']);
|
Router::get('/{address_id:\d+}', [UserController::class, 'getUserAddressInfo']);
|
||||||
|
|
||||||
// 修改地址
|
// 添加用户收获地址列表
|
||||||
Router::put('', [CallBackController::class, 'imCallBack']);
|
Router::post('', [UserController::class, 'addUserAddress']);
|
||||||
|
|
||||||
// 删除地址
|
// 修改用户收获地址列表
|
||||||
Router::delete('', [CallBackController::class, 'imCallBack']);
|
Router::put('/{address_id:\d+}', [UserController::class, 'putUserAddress']);
|
||||||
|
|
||||||
|
// 删除用户收获地址列表
|
||||||
|
Router::delete('/{address_id:\d+}', [UserController::class, 'deleteUserAddress']);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 未开发接口
|
// 未开发接口
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user