main
yanzai 11 months ago
commit 5887857ea6

19
.gitignore vendored

@ -0,0 +1,19 @@
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.idea
.env.backup
.phpunit.result.cache
docker-compose.override.yml
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
/.idea
/.vscode
pnpm-lock.yaml
h5/node_modules
Laravel/composer.lock

@ -0,0 +1,18 @@
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[*.{yml,yaml}]
indent_size = 2
[docker-compose.yml]
indent_size = 4

@ -0,0 +1,52 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DRIVER=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
MEMCACHED_HOST=127.0.0.1
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

@ -0,0 +1,10 @@
* text=auto
*.blade.php diff=html
*.css diff=css
*.html diff=html
*.md diff=markdown
*.php diff=php
/.github export-ignore
CHANGELOG.md export-ignore

15
Laravel/.gitignore vendored

@ -0,0 +1,15 @@
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.phpunit.result.cache
docker-compose.override.yml
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
/.idea
/.vscode

@ -0,0 +1,14 @@
php:
preset: laravel
version: 8
disabled:
- no_unused_imports
finder:
not-name:
- index.php
- server.php
js:
finder:
not-name:
- webpack.mix.js
css: true

@ -0,0 +1,64 @@
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400"></a></p>
<p align="center">
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
</p>
## About Laravel
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
- [Simple, fast routing engine](https://laravel.com/docs/routing).
- [Powerful dependency injection container](https://laravel.com/docs/container).
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
- [Robust background job processing](https://laravel.com/docs/queues).
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
Laravel is accessible, powerful, and provides tools required for large, robust applications.
## Learning Laravel
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
## Laravel Sponsors
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).
### Premium Partners
- **[Vehikl](https://vehikl.com/)**
- **[Tighten Co.](https://tighten.co)**
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
- **[64 Robots](https://64robots.com)**
- **[Cubet Techno Labs](https://cubettech.com)**
- **[Cyber-Duck](https://cyber-duck.co.uk)**
- **[Many](https://www.many.co.uk)**
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
- **[DevSquad](https://devsquad.com)**
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
- **[OP.GG](https://op.gg)**
- **[WebReinvent](https://webreinvent.com/?utm_source=laravel&utm_medium=github&utm_campaign=patreon-sponsors)**
- **[Lendio](https://lendio.com)**
## Contributing
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
## Code of Conduct
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
## Security Vulnerabilities
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
## License
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

@ -0,0 +1,59 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Console\GeneratorCommand;
class MakeService extends GeneratorCommand
{
/**
* 控制台命令名称
*
* @var string
*/
protected $name = 'make:service';
/**
* 控制台命令描述
*
* @var string
*/
protected $description = 'Create a new service class';
/**
* 生成类的类型
*
* @var string
*/
protected $type = 'Services';
/**
* 获取生成器的存根文件
*
* @return string
*/
protected function getStub()
{
return __DIR__ . '/Stubs/services.stub';
}
/**
* 获取类的默认命名空间
*
* @param string $rootNamespace
* @return string
*/
protected function getDefaultNamespace($rootNamespace)
{
return $rootNamespace . '\Services';
}
}

@ -0,0 +1,7 @@
<?php
namespace DummyNamespace;
class DummyClass
{
}

@ -0,0 +1,34 @@
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')->hourly();
}
/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');
MakeService::class;
require base_path('routes/console.php');
}
}

@ -0,0 +1,41 @@
<?php
namespace App\Exceptions;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
*
* @var array<int, class-string<Throwable>>
*/
protected $dontReport = [
//
];
/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array<int, string>
*/
protected $dontFlash = [
'current_password',
'password',
'password_confirmation',
];
/**
* Register the exception handling callbacks for the application.
*
* @return void
*/
public function register()
{
$this->reportable(function (Throwable $e) {
//
});
}
}

@ -0,0 +1,38 @@
<?php
namespace App\Http\Controllers\API\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Services\Admin\MenuService;
use App\Services\Admin\UserService;
class BaseInfoController extends Controller
{
//登录后获取admin后台自身菜单列表
public function GetBaseMenuList(Request $request){
$userid = $request->get('userid');//中间件产生的参数
$group = $request->get('role');//中间件产生的参数
$s=app()->make(MenuService::class);
// dd($s->GetBaseMenuList(['userid'=>$userid,'group'=>$group]));
return $s->GetBaseMenuList(['userid'=>$userid,'group'=>$group]);
}
//获取自身基本信息
public function GetBaseUserInfo(Request $request){
$userid = $request->get('userid');//中间件产生的参数
$group = $request->get('role');//中间件产生的参数
$s=app()->make(UserService::class);
return $s->GetDetail(['id'=>$userid]);
}
//检查用户是否有某个目录的权限
public function CheckMenuAuth(Request $request){
$userid = $request->get('userid');//中间件产生的参数
$group = $request->get('role');//中间件产生的参数
$url= request('url');
$s=app()->make(UserService::class);
return $s->CheckMenuAuth(['userid'=>$userid,'group'=>$group,'url'=>$url]);
}
}

@ -0,0 +1,32 @@
<?php
namespace App\Http\Controllers\API\Admin;
use App\Http\Controllers\Controller;
use App\Services\ConfigService;
use Illuminate\Http\Request;
class ConfigController extends Controller
{
//获取站点配置信息
public function GetConfigInfo(Request $request){
$userid = $request->get('userid');//中间件产生的参数
$group=$request->get('role');
$is_admin=false;
if(in_array($group,[1])){
$is_admin=true;
}
$configs = new ConfigService();
return $configs->GetConfigInfo(['站点名称','站点图片'],$is_admin);
}
public function SaveConfig(){
$data = request('data');
if(count($data)>0){
$configs = new ConfigService();
return $configs->SaveConfig($data);
}
}
}

@ -0,0 +1,45 @@
<?php
namespace App\Http\Controllers\APi\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Services\Admin\GroupService;
use App\Services\Admin\MenuService;
class GroupController extends Controller
{
//获取全部组
public function GetList(){
$type =request('type');
$page =request('page');
$pagesize =request('pagesize');
$s=app()->make(GroupService::class);
return $s->GetList(['type'=>$type,'page'=>$page,'pagesize'=>$pagesize]);
}
public function ChangeMenu(Request $request){
$userid = $request->get('userid');//中间件产生的参数
$group =request('groupId');
$menuList =request('menuList');
$s=app()->make(GroupService::class);
return $s->ChangeMenu(['groupid'=>$group,'menuList'=>$menuList]);
}
public function Save(){
$groupInfo =request('groupInfo');
$type =request('type');
$s=app()->make(GroupService::class);
return $s->Save(['info'=>$groupInfo,'type'=>$type]);
}
//管理员查询分组使用的菜单
public function GetGroupMenuList(){
$groupId =request('groupId');
if($groupId){
$group =$groupId;
$userid='search';
$s=app()->make(MenuService::class);
// dd($s->GetBaseMenuList(['userid'=>$userid,'group'=>$group]));
return $s->GetBaseMenuList(['userid'=>$userid,'group'=>$group]);
}
}
}

@ -0,0 +1,21 @@
<?php
namespace App\Http\Controllers\API\Admin;
use App\Http\Controllers\Controller;
use App\Services\Login\LoginService;
use Illuminate\Http\Request;
use Yz;
use App\Lib\HSM;
use App\Lib\XTSign;
class LoginController extends Controller
{
public function Login(){
$username =request('username');
$password= request('password');
$login=app()->make(LoginService::class);
//$login= new LoginService();
return Yz::echo($login->Login(['username'=>$username,'password'=>$password]));
}
}

@ -0,0 +1,45 @@
<?php
namespace App\Http\Controllers\API\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Services\Admin\MenuService;
use Yz;
class MenuController extends Controller
{
//获取全部菜单
public function GetList(){
$type =request('type');
$page =request('page');
$pagesize =request('pagesize');
$s=app()->make(MenuService::class);
return $s->GetList(['type'=>$type,'page'=>$page,'pagesize'=>$pagesize]);
}
//获取可用的一级菜单
public function GetFatherMenuList(){
$s=app()->make(MenuService::class);
return $s->GetFatherMenuList();
}
public function AddMenu(){
$menuInfo =request('menuInfo');
if($menuInfo['id']){
if(!($menuInfo['name'] and $menuInfo['pid'] and $menuInfo['url'])){
return Yz::echoError('请填写全部信息');
}
}else{
if(!($menuInfo['name'])){
return Yz::echoError('请填写全部信息');
}
}
$s=app()->make(MenuService::class);
return $s->AddMenu(['info'=>$menuInfo]);
}
public function EditMenu(){
$menuInfo =request('menuInfo');
$s=app()->make(MenuService::class);
return $s->EditMenu(['info'=>$menuInfo]);
}
}

@ -0,0 +1,113 @@
<?php
namespace App\Http\Controllers\API\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class QuestionItemController extends Controller
{
public function item(Request $request)
{
$items = DB::table('items')
->select(['item_id', 'name', 'pinyin', 'sex'])
->get();
return \Yz::Return(true, '操作完成', [
'list' => $items
]);
}
public function combo(Request $request)
{
$combos = DB::table('combos')
->select(['combo_id', 'name', 'pinyin'])
->get();
return \Yz::Return(true, '操作完成', [
'list' => $combos
]);
}
public function create(Request $request)
{
$name = $request->post('name');
$desc = $request->post('desc');
$jichu = $request->post('jichu');
$tuijian = $request->post('tuijian');
$gaoduan = $request->post('gaoduan');
if (!$name) {
return \Yz::echoError('请填写项目名称');
}
if (mb_strlen($name) > 20) {
return \Yz::echoError('项目名称过长');
}
if (mb_strlen($desc) > 200) {
return \Yz::echoError('项目说明过长');
}
DB::table('question_items')->insert([
'name' => $name,
'desc' => $desc ?? '',
'jichu' => $jichu ?? '[]',
'tuijian' => $tuijian ?? '[]',
'gaoduan' => $gaoduan ?? '[]',
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s'),
]);
return \Yz::Return(true, '操作完成');
}
public function update(Request $request)
{
$id = $request->post('id');
$name = $request->post('name');
$desc = $request->post('desc');
$jichu = $request->post('jichu');
$tuijian = $request->post('tuijian');
$gaoduan = $request->post('gaoduan');
if (!$name) {
return \Yz::echoError('请填写项目名称');
}
if (mb_strlen($name) > 20) {
return \Yz::echoError('项目名称过长');
}
if (mb_strlen($desc) > 200) {
return \Yz::echoError('项目说明过长');
}
DB::table('question_items')->where('id', $id)->update([
'name' => $name,
'desc' => $desc ?? '',
'jichu' => $jichu ?? '[]',
'tuijian' => $tuijian ?? '[]',
'gaoduan' => $gaoduan ?? '[]',
'updated_at' => date('Y-m-d H:i:s'),
]);
return \Yz::Return(true, '操作完成');
}
public function delete(Request $request)
{
$id = $request->post('id');
DB::table('question_items')->where('id', $id)->delete();
return \Yz::Return(true, '操作完成');
}
public function list(Request $request)
{
$search = $request->post('search');
$db = DB::table('question_items');
if (!!$search) {
$db->where('name', $search);
}
$list = $db->orderBy('id', 'desc')->paginate(20);
return \Yz::Return(true, '操作完成', [
'list' => $list
]);
}
public function select(Request $request)
{
$list = DB::table('question_items')->select(['id', 'name'])->get();
return \Yz::Return(true, '操作完成', [
'list' => $list
]);
}
}

@ -0,0 +1,104 @@
<?php
namespace App\Http\Controllers\API\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class QuestionListController extends Controller
{
public function create(Request $request)
{
$name = $request->post('name');
$desc = $request->post('desc');
$icon = $request->post('icon');
$order = $request->post('order');
$question = $request->post('question');
if (!$question) {
return \Yz::echoError('请选择问卷');
}
if (!$name) {
return \Yz::echoError('请填写名称');
}
if (mb_strlen($name) > 20) {
return \Yz::echoError('名称过长');
}
if (mb_strlen($desc) > 200) {
return \Yz::echoError('说明过长');
}
if (!$icon) {
return \Yz::echoError('请上传图片');
}
if (mb_strlen($icon) > 200) {
return \Yz::echoError('图片链接过长');
}
DB::table('question_lists')->insert([
'name' => $name,
'desc' => $desc ?? '',
'icon' => $icon,
'order' => $order ?? 0,
'question' => $question ?? 0,
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s'),
]);
return \Yz::Return(true, '操作完成');
}
public function update(Request $request)
{
$id = $request->post('id');
$name = $request->post('name');
$desc = $request->post('desc');
$icon = $request->post('icon');
$order = $request->post('order');
$question = $request->post('question');
if (!$question) {
return \Yz::echoError('请选择问卷');
}
if (!$name) {
return \Yz::echoError('请填写名称');
}
if (mb_strlen($name) > 20) {
return \Yz::echoError('名称过长');
}
if (mb_strlen($desc) > 200) {
return \Yz::echoError('说明过长');
}
if (!$icon) {
return \Yz::echoError('请上传图片');
}
if (mb_strlen($icon) > 200) {
return \Yz::echoError('图片链接过长');
}
DB::table('question_lists')->where('id', $id)->update([
'name' => $name,
'desc' => $desc ?? '',
'icon' => $icon,
'order' => $order ?? 0,
'question' => $question ?? 0,
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s'),
]);
return \Yz::Return(true, '操作完成');
}
public function delete(Request $request)
{
$id = $request->post('id');
DB::table('question_lists')->where('id', $id)->delete();
return \Yz::Return(true, '操作完成');
}
public function list(Request $request)
{
$search = $request->post('search');
$db = DB::table('question_lists');
if (!!$search) {
$db->where('name', 'like', "%$search%");
}
$list = $db->orderBy('order', 'desc')->get();
return \Yz::Return(true, '操作完成', [
'list' => $list
]);
}
}

@ -0,0 +1,88 @@
<?php
namespace App\Http\Controllers\API\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class QuestionQuestionController extends Controller
{
public function create(Request $request)
{
$question = $request->post('question');
$type = $request->post('type');
$option = $request->post('option');
if (!$question) {
return \Yz::echoError('请填写题目');
}
if (mb_strlen($question) > 200) {
return \Yz::echoError('题目过长');
}
$type_array = ['select', 'input', 'city', 'date'];
if (!in_array($type, $type_array)) {
return \Yz::echoError('题目类型异常');
}
DB::table('question_questions')->insert([
'question' => $question,
'type' => $type,
'option' => $option ?? '{}',
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s'),
]);
return \Yz::Return(true, '操作完成');
}
public function update(Request $request)
{
$id = $request->post('id');
$question = $request->post('question');
$type = $request->post('type');
$option = $request->post('option');
if (!$question) {
return \Yz::echoError('请填写题目');
}
if (mb_strlen($question) > 200) {
return \Yz::echoError('题目过长');
}
$type_array = ['select', 'input', 'city', 'date'];
if (!in_array($type, $type_array)) {
return \Yz::echoError('题目类型异常');
}
DB::table('question_questions')->where('id', $id)->update([
'question' => $question,
'type' => $type,
'option' => $option ?? '{}',
'updated_at' => date('Y-m-d H:i:s'),
]);
return \Yz::Return(true, '操作完成');
}
public function delete(Request $request)
{
$id = $request->post('id');
DB::table('question_questions')->where('id', $id)->delete();
return \Yz::Return(true, '操作完成');
}
public function list(Request $request)
{
$search = $request->post('search');
$db = DB::table('question_questions');
if (!!$search) {
$db->where('question', 'like', "%$search%");
}
$list = $db->orderBy('id', 'desc')->paginate(20);
return \Yz::Return(true, '操作完成', [
'list' => $list
]);
}
public function select(Request $request)
{
$list = DB::table('question_questions')->select(['id', 'question'])->get();
return \Yz::Return(true, '操作完成', [
'list' => $list
]);
}
}

@ -0,0 +1,97 @@
<?php
namespace App\Http\Controllers\API\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class QuestionnaireController extends Controller
{
public function create(Request $request)
{
$type = $request->post('type');
$name = $request->post('name');
$items = $request->post('items');
$questions = $request->post('questions');
if (!$name) {
return \Yz::echoError('请填写问卷名称');
}
if (mb_strlen($name) > 50) {
return \Yz::echoError('问卷名称过长');
}
$type_array = ['检前评估', '问卷调查'];
if (!in_array($type, $type_array)) {
return \Yz::echoError('问卷类型异常');
}
DB::table('questionnaires')->insert([
'type' => $type,
'name' => $name,
'items' => $items ?? '[]',
'questions' => $questions ?? '[]',
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s'),
]);
return \Yz::Return(true, '操作完成');
}
public function update(Request $request)
{
$id = $request->post('id');
$type = $request->post('type');
$name = $request->post('name');
$items = $request->post('items');
$questions = $request->post('questions');
if (!$name) {
return \Yz::echoError('请填写问卷名称');
}
if (mb_strlen($name) > 50) {
return \Yz::echoError('问卷名称过长');
}
$type_array = ['检前评估', '问卷调查'];
if (!in_array($type, $type_array)) {
return \Yz::echoError('问卷类型异常');
}
DB::table('questionnaires')->where('id', $id)->update([
'type' => $type,
'name' => $name,
'items' => $items ?? '[]',
'questions' => $questions ?? '[]',
'updated_at' => date('Y-m-d H:i:s'),
]);
return \Yz::Return(true, '操作完成');
}
public function delete(Request $request)
{
$id = $request->post('id');
DB::table('questionnaires')->where('id', $id)->delete();
return \Yz::Return(true, '操作完成');
}
public function list(Request $request)
{
$search = $request->post('search');
$type = $request->post('type');
$db = DB::table('questionnaires');
if (!!$search) {
$db->where('name', 'like', "%$search%");
}
if (!!$type) {
$db->where('type', $type);
}
$list = $db->orderBy('id', 'desc')->paginate(20);
return \Yz::Return(true, '操作完成', [
'list' => $list
]);
}
public function select(Request $request)
{
$db = DB::table('questionnaires');
$list = $db->select(['id', 'name'])->where('type', '问卷调查')->orderBy('id', 'desc')->get();
return \Yz::Return(true, '操作完成', [
'list' => $list
]);
}
}

@ -0,0 +1,49 @@
<?php
namespace App\Http\Controllers\API\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Services\Admin\UserService;
class UserController extends Controller
{
public function GetInfoList(){
$page =request('page');
$pagesize =request('pageSize');
$s=app()->make(UserService::class);
return $s->GetInfoList(['page'=>$page,'pagesize'=>$pagesize]);
}
public function Save(){
$userInfo =request('userInfo');
$s=app()->make(UserService::class);
return $s->Save(['info'=>$userInfo]);
}
public function GetDetail(){
$id =request('id');
$s=app()->make(UserService::class);
return $s->GetDetail(['id'=>$id]);
}
public function ChangePwd(Request $request){ //admin修改密码
$userid = $request->get('userid');//中间件产生的参数
$oldpwd =request('oldpwd');
$newpwd =request('newpwd');
if($oldpwd and $newpwd){
$s=app()->make(UserService::class);
return $s->ChangePwd(['id'=>$userid,'oldpwd'=>$oldpwd,'newpwd'=>$newpwd]);
}else{
return \Yz::echoError("参数不完整");
}
}
//修改自身信息
public function ChangInfo(Request $request){
$userid = $request->get('userid');//中间件产生的参数
$headimg =request('headimg');
$name =request('name');
if(!isset($name)) return \Yz::echoError1('名称不可为空');
$ser=new UserService();
return $ser->ChangInfo(['userid'=>$userid,'name'=>$name,'headimg'=>$headimg]);
}
}

@ -0,0 +1,59 @@
<?php
namespace App\Http\Controllers\API\Admin\YeWu;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class AnalysisTypeController extends Controller
{
public function GetList(){
$list = DB::table('analysis_types')->get();
return \Yz::Return(true,"查询完成",['list'=>$list]);
}
public function GetDetail()
{
$id = request('id');
$detail = DB::table('analysis_types')->where('id',$id)->first();
if(!!$detail){
$detail->range=json_decode($detail->range,true);
if(isset($detail->range['l'])){
$detail->range['l']=implode(',',$detail->range['l']);
}
if(isset($detail->range['r'])){
$detail->range['r']=implode(',',$detail->range['r']);
}
}
return \Yz::Return(true,"查询完成",['info'=>$detail]);
}
public function Save(){
$info = request('Info');
$range=[
"s"=>isset($info['range']['s'])?$info['range']['s']:0,
"r"=>isset($info['range']['r'])?explode(',', $info['range']['r']):[],
"l"=>isset($info['range']['l'])?explode(',', $info['range']['l']):[],
];
$data=[
'name'=>isset($info['name'])?$info['name']:'',
'range'=>json_encode($range,JSON_UNESCAPED_UNICODE),
'desc'=>isset($info['desc'])?$info['desc']:'',
'color'=>isset($info['color'])?$info['color']:'#78A155',
'mark'=>isset($info['mark'])?$info['mark']:'',
'content'=>isset($info['content'])?$info['content']:'',
'type'=>isset($info['type'])?$info['type']:0,
'status'=>isset($info['status'])?$info['status']:0,
];
if(isset($info['id']) and $info['id']>0){
$u= DB::table('analysis_types')->where('id',$info['id'])->update($data);
}else{
$u= DB::table('analysis_types')->insert($data);
}
if($u){
return \Yz::Return(true,"操作完成",[]);
}else{
return \Yz::echoError1("操作失败");
}
}
}

@ -0,0 +1,66 @@
<?php
namespace App\Http\Controllers\API\Admin\YeWu;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class ArticleController extends Controller
{
public function GetList()
{
$searchInfo=request('searchInfo');
$list = DB::table('articles')->where(['type'=>$searchInfo['ArticleType'],'is_del'=>0,'status'=>1]);
$count=$list->count();
$list=$list->orderBy('order','asc')->get();
return \Yz::Return(true,"查询完成",['list'=>$list,'count'=>$count]);
}
public function Save()
{
$Info=request('Info');
if(!isset($Info['id'])) return \Yz::echoError1("id不能为空");
$data=[
'title'=>$Info['title'],
'type'=>$Info['type'],
'head_img'=>isset($Info['head_img'])?$Info['head_img']:'',
'content'=>isset($Info['content'])?$Info['content']:'',
'author'=>isset($Info['author'])?$Info['author']:'',
'order'=>isset($Info['order'])?$Info['order']:0,
];
$do=false;
if($Info['id']===0){
$do=DB::table('articles')->insert($data);
}else{
$do= DB::table('articles')->where(['id'=>$Info['id'],'is_del'=>0])->update($data);
}
if($do){
return \Yz::Return(true,"操作成功",[]);
}else{
return \Yz::echoError1("操作失败");
}
}
//获取详情
public function GetDetail()
{
$id=request('id');
$info = DB::table('articles')->where(['id'=>$id,'is_del'=>0,'status'=>1])->first();
if($info){
return \Yz::Return(true,"查询完成",$info);
}else{
return \Yz::echoError1("文章内容查询失败");
}
}
public function Del()
{
$id=request('id');
$d=DB::table('articles')->where(['id'=>$id])->update(['is_del'=>1]);
if($d){
return \Yz::Return(true,"操作完成",[]);
}else{
return \Yz::echoError1("删除失败");
}
}
}

@ -0,0 +1,17 @@
<?php
namespace App\Http\Controllers\API\Admin\YeWu;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class CheckUpTypeController extends Controller
{
//体检类型列表
public function GetEnableList()
{
$list=DB::table('checkup_type')->where(['is_del'=>0,'status'=>1])->get();
return \Yz::Return(true,'查询完成',['list'=>$list]);
}
}

@ -0,0 +1,242 @@
<?php
namespace App\Http\Controllers\API\Admin\YeWu;
use App\Http\Controllers\API\PEISApiController;
use App\Http\Controllers\Controller;
use DateTime;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class ComboController extends Controller
{
//获取套餐
public function UpdateCombo()
{
$hospital_id = request('hospital');
date_default_timezone_set('PRC');
$data = [
"价格下限" => "0", "价格上限" => "999999", "性别" => null, "妇检" => false
];
$peis = new PEISApiController();
$info = $peis::Post('套餐查询', $hospital_id, $data, false);
$successCount = 0;//成功的数量
if (count($info['data']) > 0) {
$combos = $info['data'];
//查询医院下所有缓存的套餐
$db_combo_all = DB::table('combos')->where(['hospital_id' => $hospital_id])->get();
foreach ($db_combo_all as $key => $db_combo) {
$cunzai = false;
foreach ($combos as $c_key => $combo) {
if ($db_combo->combo_id == $combo['Id']) {
$cunzai = true;
}
}
if (!$cunzai) {
DB::table('combos')->where(['id' => $db_combo->id])->update([
'status' => 0
]);
}
}
foreach ($combos as $c_key => $combo) {
$sixin_combo_item_ids=[];//思信套餐内项目ids
$item = [];
$comboDetail = $peis::Post('套餐详情查询', $hospital_id, ['套餐Id' => $combo['Id']], false);
if ($comboDetail['code'] != 0) return \Yz::echoError1("套餐详情查询失败");
$comboDetail_list = $comboDetail['data'][0]['包含项目'];
foreach ($comboDetail_list as $key => $v) {
$sixin_combo_item_ids[]=$v['Id'];
//在独立表中缓存一份套餐对应的项目信息
$item_sex = null;
if (isset($v['性别限制'])) {
$item_sex_array = ['全部' => 0, '男' => 1, '女' => 2];
$item_sex = $item_sex_array[$combo['性别限制']] >= 0 ? $item_sex_array[$combo['性别限制']] : null;
}
$item_date = [
'combo_id'=>$combo['Id'],
'item_id'=>$v['Id'],
'name'=>$v['名称'],
'desc' => $v['简介'],
'keshi_id' => $v['科室Id'],
'keshi_name' => $v['科室名称'],
'price'=> $v['价格'],
'sex'=>$item_sex,
'can_qian_hou'=>$v['餐前餐后'],
'status'=>1
];
$db_combo_item = DB::table('combo_items')->where(['item_id' => $v['Id'], 'combo_id' => $combo['Id']])->first();
if (!!$db_combo_item) {
//如果存在项目
$u = DB::table('combo_items')->where(['id' => $db_combo_item->id])->update($item_date);
} else {
//如果不在项目
$u = DB::table('combo_items')->insert($item_date);
}
$item[] = [
'id' => $v['Id'],
'name' => $v['名称'],
'desc' => $v['备注'],
'keshi_name' => $v['科室名称'],
];
}
//查询当前套餐缓存的套餐项目ids
$db_combo_item_ids=DB::table('combo_items')
->where(['combo_id' => $combo['Id']])->pluck('item_id')->toArray();
// 查询在库里缓存但思信已经没有的项目ids,标注为弃用0
$k_ids = array_diff($db_combo_item_ids, $sixin_combo_item_ids);
if(count($k_ids)>0){
DB::table('combo_items')->where(['combo_id'=>$combo['Id']])->whereIn('item_id',$k_ids)->delete();
}
$item = json_encode($item, JSON_UNESCAPED_UNICODE);
$sex = null;
if (isset($combo['性别限制'])) {
$sex_array = ['全部' => 0, '男' => 1, '女' => 2];
$sex = $sex_array[$combo['性别限制']] >= 0 ? $sex_array[$combo['性别限制']] : null;
}
$db_combo = DB::table('combos')->where(['hospital_id' => $hospital_id, 'combo_id' => $combo['Id']])->first();
$comboData = [
'hospital_id' => $hospital_id,
'combo_id' => $combo['Id'],
'sex' => $sex,
'name' => $combo['名称'],
'pinyin' => $combo['拼音'],
'original_price' => $combo['原价'],
'price' => $combo['价格'],
'items' => $item,
'item_count' => $comboDetail['data'][0]['项目数量'],
'duo_xuan_yi'=>json_encode($combo['包含多选一组'], JSON_UNESCAPED_UNICODE),
'keyue_start_time' => $combo['可约开始时间'],
'keyue_end_time' => $combo['可约截止时间'],
'status' => 1,
'updated_at' => date('Y-m-d H:i:s'),
];
if (!!$db_combo) {
//如果存在套餐
$u = DB::table('combos')->where(['hospital_id' => $hospital_id, 'combo_id' => $combo['Id']])->update($comboData);
} else {
//如果不存在套餐
$comboData['tags'] = json_encode([]);
$comboData['tags2'] = json_encode([]);
$u = DB::table('combos')->insert($comboData);
}
if ($u) {
$successCount++;
} else {
return \Yz::echoError1('更新失败');
}
}
$hospital = DB::table('hospitals')->where(['id' => $hospital_id])->first();
if (!!$hospital->frequency) {
$date = new DateTime();
$date->modify('+' . $hospital->frequency . ' minutes');
$formatted_time = $date->format('Y-m-d H:i:s');
DB::table("hospitals")->where(['id' => $hospital_id])->update([
'next_time' => $formatted_time
]);
}
return \Yz::Return(true, '操作完成', ['success_count' => $successCount, 'combos_count' => count($combos)]);
} else {
return \Yz::echoError1('未查询到套餐');
}
}
public function GetList()
{
$page = request('page');
$pageSize = request('pageSize');
$searchInfo = request('searchInfo');
$type=request('type');
$list = DB::table('combos')
->select('combos.*', 'hospitals.name as hospital_name', 'combo_type.name as combo_type_name', 'combo_crowd.name as combo_crowd_name')
->leftJoin('hospitals', 'hospitals.id', '=', 'combos.hospital_id')
->leftJoin('combo_type', 'combos.type_id', '=', 'combo_type.id')
->leftJoin('combo_crowd', 'combos.crowd_id', '=', 'combo_crowd.id');
if (isset($searchInfo['name'])) {
$list = $list->where('combos.name', 'like', '%' . $searchInfo['name'] . '%');
}
$list=$list->where(['combos.status'=>1]);
$count = $list->count();
if(isset($type) and $type=='all'){
$list = $list->orderBy('combos.order','asc')->get();
}else{
$list = $list->orderBy('combos.order','asc')
->skip(($page - 1) * $pageSize) // 跳过前9999条记录
->take($pageSize)->get();
}
return \Yz::Return(true, "查询完成", ['list' => $list, 'count' => $count]);
}
public function GetAllList(){
$list = DB::table('combos')->get();
return \Yz::Return(true, "查询完成", ['list' => $list]);
}
public function GetDetail()
{
$id = request('id');
$query = DB::table('combos')->where(['id' => $id])->first();
if (!!$query) {
$query->tags = implode(", ", json_decode($query->tags, true));
$query->tags2 = implode(", ", json_decode($query->tags2, true));
$query->items = json_decode($query->items);
return \Yz::Return(true, "查询完成", $query);
} else {
return \Yz::echoError1("获取详情失败");
}
}
public function Save()
{
$Info = request('Info');
$u = DB::table('combos')->where(['id' => $Info['id']])->update([
'checkup_type_id' => $Info['checkup_type_id'],
'type_id' => $Info['type_id'],
'crowd_id' => $Info['crowd_id'],
'tags' => isset($Info['tags']) ? json_encode($Info['tags'], JSON_UNESCAPED_UNICODE) : [],
'tags2' => isset($Info['tags2']) ? json_encode($Info['tags2'], JSON_UNESCAPED_UNICODE) : [],
'cover' => $Info['cover'],
'intro' => $Info['intro'],
'sub_intro' => $Info['sub_intro'],
'desc' => $Info['desc'],
'order' => $Info['order'],
'sale_count' => $Info['sale_count'],
'is_hot' => isset($Info['is_hot'])?$Info['is_hot']:0,
]);
if ($u) {
return \Yz::Return(true, "更新完成", []);
} else {
return \Yz::echoError1("没有数据更新");
}
}
//保存排序
public function SaveOrder(){
$order_list = request('order_list');
$count=0;
foreach ($order_list as $order) {
$u=DB::table('combos')->where(['id' => $order['id']])->update(['order' => $order['order']]);
if ($u) {
$count++;
}
}
if ($count) {
return \Yz::Return(true, "更新完成", []);
} else {
return \Yz::echoError1("没有数据更新");
}
}
}

@ -0,0 +1,45 @@
<?php
namespace App\Http\Controllers\API\Admin\YeWu;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class ComboCrowdController extends Controller
{
//获取适用人群列表
public function GetList()
{
$list=DB::table('combo_crowd')->get();
return \Yz::Return(true,'查询成功',['list'=>$list]);
}
public function Save()
{
$Info=request('Info');
$data=['name'=>$Info['name']];
$u=false;
if(isset($Info['id']) and $Info['id']<>0){
//更新
$u=DB::table('combo_crowd')->where('id',$Info['id'])->update($data);
}else{
//添加
$u=DB::table('combo_crowd')->insert($data);
}
if($u){
return \Yz::Return(true,"操作完成",[]);
}else{
return \Yz::echoError1("操作失败");
}
}
public function Del(){
$id=request('id');
$d=DB::table('combo_crowd')->where('id',$id)->delete();
if($d){
return \Yz::Return(true,"操作完成",[]);
}else{
return \Yz::echoError1("操作失败");
}
}
}

@ -0,0 +1,43 @@
<?php
namespace App\Http\Controllers\API\Admin\YeWu;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class ComboTypeController extends Controller
{
public function GetList()
{
$list=DB::table('combo_type')->get();
return \Yz::Return(true,'查询成功',['list'=>$list]);
}
public function Save()
{
$Info=request('Info');
$data=['name'=>$Info['name']];
$u=false;
if(isset($Info['id']) and $Info['id']<>0){
//更新
$u=DB::table('combo_type')->where('id',$Info['id'])->update($data);
}else{
//添加
$u=DB::table('combo_type')->insert($data);
}
if($u){
return \Yz::Return(true,"操作完成",[]);
}else{
return \Yz::echoError1("操作失败");
}
}
public function Del(){
$id=request('id');
$d=DB::table('combo_type')->where('id',$id)->delete();
if($d){
return \Yz::Return(true,"操作完成",[]);
}else{
return \Yz::echoError1("操作失败");
}
}
}

@ -0,0 +1,81 @@
<?php
namespace App\Http\Controllers\API\Admin\YeWu;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class CouponsController extends Controller
{
public function GetList()
{
$list = DB::table('coupons')->where(['is_del'=>0])->get();
return \Yz::Return(true, '查询成功', ['list' => $list]);
}
public function Save()
{
$Info = request('Info');
if (!isset($Info['name'])) return \Yz::echoError1("名称不能为空");
if (!isset($Info['his_id'])) return \Yz::echoError1("Id不能为空");
if (!isset($Info['type'])) return \Yz::echoError1("类型不能为空");
$data = [
'name' => $Info['name'],
'type' => $Info['type'],
'his_id' => $Info['his_id'],
'updated_at' => date("Y-m-d H:i:s"),
];
$u = false;
if (isset($Info['id']) and $Info['id'] <> 0) {
//更新
$u = DB::table('coupons')->where('id', $Info['id'])->update($data);
DB::table('coupons_combos')->where('coupon_hisid', $Info['his_id'])->delete();
} else {
$cha=DB::table('coupons')->where(['his_id'=> $Info['his_id']])->first();
if(!!$cha) return \Yz::echoError1("已存在id相同的代金券不可重复复添加");
//添加
$u = DB::table('coupons')->insert($data);
DB::table('coupons_combos')->insert([
'coupon_hisid'=>$Info['his_id'],
]);
}
if(isset($Info['combo_ids'])){
foreach ($Info['combo_ids'] as $combo_id) {
DB::table('coupons_combos')->insert([
'coupon_hisid'=>$Info['his_id'],
'combo_id'=>$combo_id,
]);
}
}
if ($u) {
return \Yz::Return(true, "操作完成", []);
} else {
return \Yz::echoError1("操作失败");
}
}
public function GetDetail()
{
$id = request('id');
$info = DB::table('coupons')->where('id', $id)->first();
$combos = DB::table('coupons_combos')->where('coupon_hisid', $info->his_id)->pluck('combo_id')->toArray();
$info->combo_ids = $combos;
return \Yz::Return(true, '查询成功', ['info' => $info]);
}
public function Del()
{
$id = request('id');
$d = DB::table('coupons')->where('id', $id)->update([
'is_del' => 1
]);
if ($d) {
return \Yz::Return(true, "操作完成", []);
} else {
return \Yz::echoError1("操作失败");
}
}
}

@ -0,0 +1,88 @@
<?php
namespace App\Http\Controllers\API\Admin\YeWu;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class HospitalController extends Controller
{
public function Save()
{
$Info =request('Info');
$data=[
'name'=>$Info['name'],
'code'=>$Info['code'],
'address'=>$Info['address'],
'longitude'=>$Info['longitude'],
'latitude'=>$Info['latitude'],
'logo'=>$Info['logo'],
'tel'=>$Info['tel'],
// 'frequency'=>$Info['frequency'],
// 'api_list'=>isset($Info['api_list'])? json_encode($Info['api_list']):null,
'status'=>$Info['status'],
];
if(isset($Info['id']) and $Info['id']!=0){
$ex=DB::table('hospitals')->where(['id'=>$Info['id']])->update($data);
}else{
$ex=DB::table('hospitals')->insert($data);
}
if($ex){
return \Yz::Return(true,"保存成功",[]);
}else{
return \Yz::echoError1("保存失败");
}
}
public function GetList()
{
$page = request('page');
$pageSize = request('pageSize');
$searchInfo = request('searchInfo');
$list =DB::table('hospitals')->where(['is_del'=>0]);
$count=$list->count();
$list=$list
->skip(($page-1)*$pageSize) // 跳过前9999条记录
->take($pageSize)->get();
return \Yz::Return(true,"查询成功",['list'=>$list,'count'=>$count]);
}
//获取可用医院列表
public function GetEnableList()
{
$list =DB::table('hospitals')->where(['is_del'=>0,'status'=>1])->get();
if(count($list)>0){
return \Yz::Return(true,"查询成功",['list'=>$list]);
}else{
return \Yz::echoError1("获取医院信息失败");
}
}
//获取医院基本信息详情
public function GetBaseInfoDetail()
{
$id = request('id');
$info=DB::table('hospitals')
->where(['id'=>$id,'is_del'=>0])->first();
if(!!$info){
$info->api_list= $info->api_list?implode(',',json_decode( $info->api_list)):'';
return \Yz::Return(true,'查询成功',$info);
}else{
return \Yz::echoError1("查询失败");
}
}
public function SaveCacheInfo()
{
$Info =request('Info');
$ex=DB::table('hospitals')->where(['id'=>$Info['id']])->update([
'frequency'=>$Info['frequency'],
'api_list'=>json_encode($Info['api_list'],JSON_UNESCAPED_UNICODE)
]);
if($ex){
return \Yz::Return(true,"保存成功",[]);
}else{
return \Yz::echoError1("保存失败");
}
}
//获取
}

@ -0,0 +1,89 @@
<?php
namespace App\Http\Controllers\API\Admin\YeWu;
use App\Http\Controllers\API\PEISApiController;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class ItemController extends Controller
{
//获取套餐
public function UpdateItem()
{
$hospital_id =request('hospital');
if(!isset($hospital_id)) return \Yz::echoError1('医院不能为空');
date_default_timezone_set('PRC');
$data=[
"价格下限"=>"0","价格上限"=>"999999","性别"=>null,"妇检"=>false,"套餐Id"=>null
];
$peis=new PEISApiController();
$info= $peis::Post('自选项目查询',$hospital_id,$data,false);
$successCount=0;//成功的数量
if(count($info['data'])>0){
$items=$info['data'];
//查询医院下所有缓存的套餐
$db_items_all=DB::table('items')->where(['hospital_id'=>$hospital_id])->get();
foreach($db_items_all as $key=>$db_items){
$cunzai=false;
foreach ($items as $c_key=>$item){
if($db_items->item_id==$item['Id']){
$cunzai=true;
}
}
if(!$cunzai){
DB::table('items')->where(['id'=>$db_items->id])->update([
'status'=>0
]);
}
}
foreach ($items as $c_key=>$item){
$sex=null;
if(isset($item['性别限制'])){
$sex_array=['全部'=>0,'男'=>1,'女'=>2];
$sex = array_key_exists($item['性别限制'], $sex_array) ? $sex_array[$item['性别限制']] : null;
}
$db_item=DB::table('items')->where(['hospital_id'=>$hospital_id,'item_id'=>$item['Id']])->first();
$ItemData=[
'hospital_id'=>$hospital_id,
'item_id'=>$item['Id'],
'sex'=>$sex,
'can_qian_hou'=>$item['餐前餐后'],
'name'=>$item['名称'],
'pinyin'=>$item['拼音'],
'price'=>$item['价格'],
'original_price'=>$item['价格'],
'is_choose'=>$item['可选']===false ? "0" : "1",
'keshi_id'=>$item['科室Id'],
'keshi_name'=>$item['科室名称'],
'beizhu'=>$item['备注'],
'jianjie'=>$item['简介'],
'tishi'=>$item['提示信息'],
'status'=>1,
'updated_at'=>date('Y-m-d H:i:s'),
];
if(!!$db_item){
//如果存在项目
$u=DB::table('items')->where(['hospital_id'=>$hospital_id,'item_id'=>$item['Id']])->update($ItemData);
}else{
//如果不存在套餐
$u= DB::table('items')->insert($ItemData);
}
if($u){
$successCount++;
}else{
return \Yz::echoError1('更新失败');
}
}
return \Yz::Return(true,'操作完成',['success_count'=>$successCount,'combos_count'=>count($items)]);
}else{
return \Yz::echoError1('未查询到套餐');
}
}
}

@ -0,0 +1,174 @@
<?php
namespace App\Http\Controllers\API\Admin\YeWu;
use App\Http\Controllers\API\AspNetZhuanController;
use App\Http\Controllers\API\XCXApiController;
use App\Http\Controllers\Controller;
use App\Services\OrderService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class OrderController extends Controller
{
public function GetList()
{
$page = request('page');
$pageSize = request('pageSize');
$searchInfo = request('searchInfo');
$list = DB::table('orders');
if (isset($searchInfo['name'])) {
$list = $list->where('name', 'like', '%' . $searchInfo['name'] . '%');
}
if (isset($searchInfo['id_number'])) {
$list = $list->where('id_number', $searchInfo['id_number']);
}
if (isset($searchInfo['order_number'])) {
$list = $list->where('order_number', $searchInfo['order_number']);
}
$count = $list->count();
$list = $list->orderBy('id', 'desc')
->skip(($page - 1) * $pageSize) // 跳过前9999条记录
->take($pageSize)->get();
return \Yz::Return(true, "查询完成", ['list' => $list, 'count' => $count]);
}
public function GetDetail()
{
$id = request('id');
$order = DB::table('orders')->where(['id' => $id])->first();
return \Yz::Return(true, "查询完成", ['info' => $order]);
}
public function Save()
{
$info = request('info');
$date = [
'note' => $info['note']
];
$u = DB::table('orders')->where(['id' => $info['id']])->update($date);
if ($u) {
return \Yz::Return(true, "操作完成", []);
} else {
return \Yz::echoError1("保存失败");
}
}
public function Refund()
{
$order_id = request('order_id');
$do_type = request('do_type');//1仅退款 2取消预约并退款
$orderInfo = DB::table('orders')->where(['id' => $order_id])->first();
if (!$orderInfo) return \Yz::echoError1("未找到有效订单");
$person = DB::table('web_user_person')->where(['id' => $orderInfo->person_id])->first();
if (!$person) return \Yz::echoError1("用户不存在");
if ($do_type == 2) {
if ($orderInfo->status !== 2) return \Yz::echoError1("订单状态异常。当前状态:" . $orderInfo->status);
if ($orderInfo->check_status == 2) return \Yz::echoError1("已登记体检,禁止退款");
//调用思信取消,恢复号源
if ($orderInfo->appointment_number <> null and $orderInfo->appointment_number <> '') {
$ap = new \App\Http\Controllers\API\H5\OrderController();
$cancel = $ap->cancel_appointment($orderInfo->hospital_id, [
'type' => $orderInfo->type,
'预约Id' => $orderInfo->appointment_number
]);
if ($cancel['code'] != 0) return \Yz::echoError1("取消预约失败," . $cancel['message']);
}
}
if (in_array($do_type, [1, 2])) {
//如果有二线取消二线
$yyid = 6;
if ($orderInfo->hospital_id == 1) {
$yyid = 6;
}
if ($orderInfo->hospital_id == 4) {
$yyid = 2;
}
$AspNet = new AspNetZhuanController();
$erxian_info = json_decode($orderInfo->erxian_appointment_info, true);
if (isset($erxian_info) and !empty($erxian_info)) {
foreach ($erxian_info as $key => $plan_nmr) {
if (isset($plan_nmr['gid'])) {
//调用接口取消二线
$erxian_status = $AspNet::ErXian(['id' => $plan_nmr['gid'], 'yyid' => $yyid, 'action' => 3], uniqid());
$erxian_info[$key]['gid'] = '';
$ex_u = DB::table('orders')->where(['id' => $orderInfo->id])->update([
'erxian_appointment_info' => json_encode($erxian_info, JSON_UNESCAPED_UNICODE),
]);
}
}
}
//如果真实支付大于0 则调用小程序退款
if ($orderInfo->true_price > 0) {
$data = [
'orderid' => $orderInfo->order_number,
'refund_order_id' => 'T' . $orderInfo->order_number,
'refund_amount' => (int)($orderInfo->true_price * 100),
'refund_reason' => "体检H5订单退款",
];
$XCX = new XCXApiController();
$res = $XCX::Post('订单退款', $data);
if ($res['data']['refund_state'] != 'SUCCESS') {
return \Yz::echoError1("退款失败" . $res['data']['refund_state']);
}
}
$now_datetime = date('Y-m-d H:i:s');
//调用接口恢复积分和预存款
$env = config('app.globals.Env');
$AspNet = new AspNetZhuanController();
$jifen_huifu_status = true;
$yucunkuan_huifu_status = true;
$r_yyid = $orderInfo->hospital_id;
if ($r_yyid == 1) {
$yyid = 6;
}
if ($r_yyid == 4) {
$yyid = 2;
}
if ($env == 'pro') { //如果是正式环境
if ($orderInfo->jifen > 0 and $orderInfo->is_refund_jifen == 0) {
$jifen_huifu_status = false;
$jifen_huifu_status = $AspNet::UseJiFen($person->ghzid, $orderInfo->jifen, $yyid, $orderInfo->id, 'tj_h5', '抵扣体检H5订单', $now_datetime);
if ($jifen_huifu_status === true) {
DB::table('orders')->where('id', $orderInfo->id)->update(['is_refund_jifen' => 1]);
}
}
if ($orderInfo->yucunkuan > 0 and $orderInfo->is_refund_yucunkuan == 0) {
$yucunkuan_huifu_status = false;
$yucunkuan_huifu_status = $AspNet::UseYuCunKuan($person->ghzid, $orderInfo->yucunkuan, $yyid, 0, $orderInfo->id, 'tj_h5', '抵扣体检H5订单', $now_datetime);
if ($yucunkuan_huifu_status === true) {
DB::table('orders')->where('id', $orderInfo->id)->update(['is_refund_yucunkuan' => 1]);
}
}
if (!empty($orderInfo->youhuiquan)) {
$youhuiquan = json_decode($orderInfo->youhuiquan, true);
$data = [
'action' => 4,
'ghzid' => $person->ghzid,
'dzjid' => $youhuiquan['id'],
'hxbz' => "H5撤销核销",
'yyid' => $yyid
];
$AspNet::YouHuiQuan($data);
}
}
DB::table('orders')->where(['id' => $order_id])->update([
'status' => 5,
'refund_time' => $now_datetime
]);
//恢复号源
$up_plan = DB::table('plans')->where(['id' => $orderInfo->plan_id, 'status' => 2])->update([
'status' => 1
]);
return \Yz::Return(true, "退款成功", []);
}
}
}

@ -0,0 +1,98 @@
<?php
namespace App\Http\Controllers\API\Admin\YeWu;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class PayController extends Controller
{
public static $appid = '8a81c1bf7bea6e9f017c119c6edf0095';
public static $appkey = '2927e4d6d0aa424297043c5f0b0bc6ae';
public static $mid = '898460180119047';
public static $tid = 'H5UWV72J';
//支付
public function MakePay()
{
$msgSrcId = request('show_id');
$title = request('title');
$total = request('total');
$openid = request('openid');
$data = [];
$data['requestTimestamp'] = date("YmdHis");
$data['mid'] = self::$mid;
$data['tid'] = self::$tid;
$data['merOrderId'] = '30ZFA'.$msgSrcId;
$data['instMid'] = 'MINIDEFAULT';
$data['orderDesc'] = $title;
$data['totalAmount'] = $total;
$data['subAppId'] = 'wxfa449edc09757390';
$data['subOpenId'] = $openid;
$data['tradeType'] = 'MINI';
$data['notifyUrl'] = 'https://tj.xdhosp.com:8123/api/pay/callback';
// $data['notifyUrl'] = 'https://a1.uniapp.sa0.online/api/pay/callback';
$body = json_encode($data);
$url = 'https://api-mop.chinaums.com/v1/netpay/wx/unified-order';
return self::curlpost($url, $body);
}
//支付查询
public function PayCheck()
{
$show_id = request('show_id');
$data = [];
$data['requestTimestamp'] = date("YmdHis", time()); // 报文请求时间
$data['mid'] = self::$mid;
$data['tid'] = self::$tid;
$data['merOrderId'] = '30ZFA' . $show_id;
$data['instMid'] = 'MINIDEFAULT'; // 业务类型
$body = json_encode($data);
$url = 'https://api-mop.chinaums.com/v1/netpay/query';
return self::curlpost($url, $body);
}
public static function curlpost($url, $body, $echo_ = false)
{
$ch = curl_init();//初始化curl
curl_setopt($ch, CURLOPT_URL, $url);//抓取指定网页
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检查
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); // 从证书中检查SSL加密算法是否存在
curl_setopt($ch, CURLOPT_POST, 1);//post提交方式
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($body),
'Authorization: ' . self::getOpenBodySig($body, $echo_)
));
if ($echo_) {
echo "<br>--------------------<br>";
var_dump($url, $body);
echo "<br>--------------------<br>";
}
$output = curl_exec($ch);//运行curl
curl_close($ch);
return json_decode($output, true);
}
public static function getOpenBodySig($body, $echo_ = false)
{
$appid = self::$appid;
$appkey = self::$appkey;
$timestamp = date("YmdHis", time());
$nonce = md5(uniqid(microtime(true), true));
$str = bin2hex(hash('sha256', $body, true));
$signature = base64_encode(hash_hmac('sha256', "$appid$timestamp$nonce$str", $appkey, true));
$authorization = "OPEN-BODY-SIG AppId=\"$appid\", Timestamp=\"$timestamp\", Nonce=\"$nonce\", Signature=\"$signature\"";
if ($echo_) {
echo "<br>--------------------<br>";
var_dump($authorization);
echo "<br>--------------------<br>";
}
return $authorization;
}
}

@ -0,0 +1,247 @@
<?php
namespace App\Http\Controllers\API\Admin\YeWu;
use App\Http\Controllers\Controller;
use App\Services\TimeService;
use DateTime;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class PlanController extends Controller
{
//创建号源
public function CreatePlan()
{
$Info = request('CPlan');
$dateRange = request('dateRange');
$Info['dateRange'] = $dateRange;
$params = [
'model_id' => isset($Info['model_id']) ? $Info['model_id'] : null,
'dateRange' => isset($Info['dateRange']) ? $Info['dateRange'] : null,
'week' => isset($Info['week']) ? $Info['week'] : null,
'workday_create' => isset($Info['workday_create']) ? $Info['workday_create'] : null,
'holiday_create' => isset($Info['holiday_create']) ? $Info['holiday_create'] : null,
];
$requiredFields = ['model_id' => '模板id', 'dateRange' => '日期', 'week' => '星期', 'workday_create' => '工作日是否生成', 'holiday_create' => '节假日是否生成'];
// 判断是否为空
foreach ($requiredFields as $key => $field) {
if (!isset($params[$key]) || $params[$key] === null) {
return \Yz::echoError1('参数 ' . $field . ' 不能为空');
}
}
if (!isset($Info['dateRange']) or count($Info['dateRange']) <> 2) {
return \Yz::echoError1('起止时间格式错误');
}
$model = DB::table('plan_model as a')->where(['a.id' => $params['model_id'], 'a.is_del' => 0, 'a.status' => 1])->first();
if (!$model) return \Yz::echoError1('模板不可用');
// $planType = DB::table('plan_type as a')->where(['a.id' => $model->plan_type, 'a.is_del' => 0, 'a.status' => 1])->first();
// if (!$planType) return \Yz::echoError1('号源类型不可用');
//查询此时间段内是否有已经生成的号源
$cha = DB::table('plans')->whereBetween('date', $Info['dateRange'])->where(['is_del'=>0])->whereIn('status',[0,1])->get();
if (count($cha) > 0) {
return \Yz::return(false, '号源重复', ['list' => $cha]);
}
//获取模板的全部时间点
// $s=new TimeService();
// $timelist=$s->TimePointsArr($model->start_time,$model->end_time,$model->interval_time);
$timelist = DB::table('plan_model_time')->where(['model_id' => $params['model_id']])->get();
if (count($timelist) < 1) return \Yz::echoError1('');
$startDate = new DateTime($Info['dateRange'][0]);
$endDate = new DateTime($Info['dateRange'][1]);
$currentDate = $startDate;
$success_count = 0;
while ($currentDate <= $endDate) {
//循环生成
$date_ymd = $currentDate->format('Y-m-d');
//查询这一天已经占用的号源
$usedPlans= DB::table('plans')->where(['date'=>$date_ymd,'status'=>2])->get();
//判断节假日是否生成
$s_day = DB::table('plan_holiday')->select('*', 'type as tp')->where(['date' => $date_ymd])->first();
if (!!$s_day) {
if ($s_day->tp == 1 and $params['workday_create'] === 0) {
$currentDate->modify('+1 day');
continue;
}
if ($s_day->tp == 2 and $params['holiday_create'] === 0) {
$currentDate->modify('+1 day');
continue;
}
}
//获取星期几 星期1=1 星期日=7
$dayOfWeek = $currentDate->format('N');
//如果星期匹配上了
if (in_array($dayOfWeek, $params['week'])) {
foreach ($timelist as $key => $time) {
$planType=null;
if(isset( $time->plan_type_id)){
$planType = DB::table('plan_type as a')->where(['a.id' => $time->plan_type_id, 'a.is_del' => 0, 'a.status' => 1])->first();
if (!$planType) return \Yz::echoError1('号源类型不可用');
}
$cleanTime = implode('', explode(':', $time->time)); // 去除冒号的时间字符串
$tiaoguo=false;
foreach ($usedPlans as $usekey => $usedPlan) { //如果有占用的号源则跳过
if($usedPlan->date==$date_ymd and $usedPlan->time==$time->time){
$tiaoguo=true;
break;
}
}
if($tiaoguo) continue;
$data = [
'model_id' => $model->id,
'date' => $date_ymd,
'week' => $dayOfWeek,
'time' => $time->time,
'type' => $time->type,
'plan_number' => substr($cleanTime, 0, 4),
'is_vip' => empty($planType)?null: $planType->is_vip,
'use_type' => empty($planType)?null:$planType->use_type,
'sex' => empty($planType)?null:$planType->sex,
'checkup_type_id' => empty($planType)?null:$planType->checkup_type_id,
'amount_limit1' =>empty($planType)?null: $planType->amount_limit1,
'amount_limit2' =>empty($planType)?null: $planType->amount_limit2,
'hospital_id' => $model->hospital_id,
'status' => 1,
'is_del' => 0
];
$i = DB::table('plans')->insert($data);
if ($i) {
$success_count++;
}
}
}
// 日期加一天
$currentDate->modify('+1 day');
}
if ($success_count > 0) {
return \Yz::Return(true, '', ['success_count' => $success_count]);
} else {
return \Yz::echoError1('没有计划被创建');
}
}
public function GetList()
{
$page = request('page');
$pageSize = request('pageSize');
$searchInfo = request('searchInfo');
$list = DB::table('plans as a')
// ->leftJoin('plan_type as b','a.plan_type','=','b.id')
// ->select('a.*','b.name as plan_type_name')
->where(['a.is_del' => 0]);
if (!isset($searchInfo['date'])) {
$searchInfo['date'] = date('Y-m-d');
}
$list = $list->where(['a.date' => $searchInfo['date']]);
$count = $list->count();
$list = $list->orderBy('a.id', 'asc')->get();
return \Yz::Return(true, '查询完成', ['list' => $list, 'count' => $count, 'date' => $searchInfo['date']]);
}
public function GetDetail()
{
$id = request('id');
$info = DB::table('plans')->where(['id' => $id,'is_del'=>0])->first();
if (!!$info) {
if(empty($info->checkup_type_id)){
$info->checkup_type_id='[]';
}
$info->checkup_type_id = json_decode($info->checkup_type_id, true);
return \Yz::Return(true, '查询完成', ['info' => $info]);
} else {
return \Yz::echoError1('查询失败');
}
}
//更新保存
public function Save()
{
$info = request('info');
if (isset($info['id'])) {
$info['checkup_type_id'] = isset($info['checkup_type_id']) ? json_encode($info['checkup_type_id']) : null;
$u = DB::table('plans')->where(['id' => $info['id']])->update([
'is_vip' => $info['is_vip'],
'use_type' => $info['use_type'],
'sex' => $info['sex'],
'checkup_type_id' => $info['checkup_type_id'],
'amount_limit1' => $info['amount_limit1'],
'amount_limit2' => $info['amount_limit2'],
'status' => $info['status'],
]);
if ($u) {
return \Yz::Return(true, '保存成功', []);
} else {
return \Yz::echoError1('操作失败');
}
}
}
//批量更新号源类型
public function BatchUpdatePlanType(){
$ids = request('ids');
$type = request('type');
$info = request('info');
$cha =DB::table('plans')->whereIn('id', $ids)->where(['status'=>2])->get();
if(count($cha) >0){
return \Yz::echoError1('有号源被占用,不能执行此操作');
}
if($type==0){
$data=[
'is_vip'=>null,
'use_type'=>null,
'sex'=>null,
'checkup_type_id'=>[],
'amount_limit1'=>null,
'amount_limit2'=>null,
'type'=>0,
];
}
if($type==1){
if(empty($info['checkup_type_id'])) return \Yz::echoError1('体检类型不能为空');
if(!isset($info['is_vip'])) return \Yz::echoError1('是否vip不能为空');
if(!isset($info['use_type'])) return \Yz::echoError1('团检/个检不能为空');
if(!isset($info['sex'])) return \Yz::echoError1('性别不能为空');
$data=[
'is_vip'=>$info['is_vip'],
'use_type'=>$info['use_type'],
'sex'=>$info['sex'],
'checkup_type_id'=>$info['checkup_type_id'],
'amount_limit1'=>isset($info['amount_limit1'])?$info['amount_limit1']:0,
'amount_limit2'=>isset($info['amount_limit2'])?$info['amount_limit2']:0,
'type'=>1,
];
}
$u=DB::table('plans')->whereIn('id', $ids)->update($data);
if ($u){
return \Yz::Return(true, '操作成功', []);
}else{
return \Yz::echoError1('操作失败');
}
}
public function Del()
{
$ids = request('ids');
$dates = request('dates');
if(empty($ids) and empty($dates)) return \Yz::echoError1("条件不完整");
$del=DB::table('plans');
if(!empty($ids)){
$del=$del ->whereIn('id', $ids);
}
if(isset($dates) and !empty($dates)){
$del=$del->whereIn('date',$dates);
}
$del=$del->whereIn('status',[0,1])->update(['is_del'=>1]);
if($del){
return \Yz::Return(true, '操作成功', []);
}else{
return \Yz::echoError1('操作失败');
}
}
}

@ -0,0 +1,26 @@
<?php
namespace App\Http\Controllers\API\Admin\YeWu;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class PlanListController extends Controller
{
public function GetList()
{
$searchInfo = request('searchInfo');
$today=date('Y-m-d');
if(empty($searchInfo['dateRange']) or count($searchInfo['dateRange'])<>2){
$searchInfo['dateRange']=[$today,$today];
}
$list=DB::select("select date,
SUM(CASE WHEN type = 0 THEN 1 ELSE 0 END) as type_0_count,
SUM(CASE WHEN type =1 THEN 1 ELSE 0 END) as type_1_count,
SUM(CASE WHEN status=2 THEN 1 ELSE 0 END) as type_used_count
from plans where date >=? and date<=? and is_del=0 GROUP BY date",$searchInfo['dateRange']);
return \Yz::Return(true,"查询完成",['list'=>$list,'dateRange'=>$searchInfo['dateRange'],'count'=>0]);
}
}

@ -0,0 +1,133 @@
<?php
namespace App\Http\Controllers\API\Admin\YeWu;
use App\Http\Controllers\Controller;
use App\Services\TimeService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class PlanModelController extends Controller
{
public function timeList()
{
$TimeRange = request('TimeRange');
if(count($TimeRange)<>2) return \Yz::echoError1('起止时间格式错误');
$interval_time = request('interval_time');
$s=new TimeService();
$list=$s->TimePointsArr($TimeRange[0],$TimeRange[1],$interval_time);
return \Yz::Return(true,"查询完成",['list' =>$list]);
}
public function GetList()
{
$page =request('page');
$pageSize =request('pageSize');
$searchInfo=request('searchInfo');
$list=DB::table('plan_model as a')
->leftJoin('plan_type as b','a.plan_type','=','b.id')
->select('a.*','b.name as plan_type_name')
->where(['a.is_del'=>0]);
if(isset($searchInfo['name'])){
$list = $list->where('a.name', 'like','%'.$searchInfo['name'].'%');
}
if(isset($searchInfo['status'])){
$list = $list->where('a.status',$searchInfo['status']);
}
$count=$list->count();
if(isset($page) and isset($pageSize)){
$list=$list->orderBy('a.id', 'desc')->limit($pageSize)->skip(($page - 1) * $pageSize)->take($pageSize);
}
$list=$list ->get();
foreach ($list as $l){
$l->y_number=json_decode($l->y_number,true);
}
return \Yz::Return(true,'查询完成',['list'=>$list,'count'=>$count]);
}
public function Save()
{
$Info =request('Info');
$Timelist =request('Timelist');
$params = [
'hospital_id' => isset($Info['hospital_id']) ? $Info['hospital_id'] :null,
'name' => isset($Info['name']) ? $Info['name'] : null,
'interval_time' => isset($Info['interval_time']) ? $Info['interval_time'] : null,
'plan_type' => isset($Info['plan_type']) ? $Info['plan_type'] : null,
'y_number' => isset($Info['y_number']) ? json_encode($Info['y_number']) : [],
'count' => isset($Info['count']) ? $Info['count'] : 0,
'status'=>isset($Info['status']) ? $Info['status'] : 0,
];
$requiredFields = ['hospital_id'=>'医院','name'=>'名称','interval_time'=>'时间间隔'];
// 判断是否为空
foreach ($requiredFields as $key=> $field) {
if (!isset($params[$key]) || $params[$key] === null) {
return \Yz::echoError1('参数 ' . $field . ' 不能为空');
}
}
if(!isset($Info['TimeRange']) or count($Info['TimeRange'])<>2){
return \Yz::echoError1('起止时间格式错误');
}
$params['start_time']=$Info['TimeRange'][0];
$params['end_time']=$Info['TimeRange'][1];
$do=false;
$table=DB::table('plan_model');
$table_model_time=DB::table('plan_model_time');
DB::beginTransaction();
if($Info['id']==0){
$model_id=$table->insertGetId($params);
}
if($Info['id']>0){
$model_id=$Info['id'];
$table->where(['id'=>$Info['id']])->update($params);
}
$model_time_data=[];
foreach ($Timelist as $key=>$value){
$model_time_data[]=[
'type'=>isset($value['plan_type_id']) ? 1 : 0,
'model_id'=>$model_id,
'time'=>$value['time'],
'type_color'=>isset($value['type_color']) ? $value['type_color'] : null,
'plan_type_id'=>isset($value['plan_type_id']) ? $value['plan_type_id'] : null,
];
}
if(count($model_time_data)>0){
DB::table('plan_model_time')->where(['model_id'=>$model_id])->delete();
$do=$table_model_time->insert($model_time_data);
}
if($do){
DB::commit();
return \Yz::Return(true,'操作成功',[]);
}else{
DB::rollBack();
return \Yz::echoError1('操作失败');
}
}
public function GetDetail()
{
$id =request('id');
$info=DB::table('plan_model')->where(['id'=>$id,'is_del'=>0])->first();
if(!!$info){
$info->TimeRange=[$info->start_time,$info->end_time];
$info->y_number=json_decode($info->y_number,true);
$list=DB::table('plan_model_time as a')->where(['model_id'=>$id])->get();
$info->list=$list;
return \Yz::Return(true,'查询完成',$info);
}else{
return \Yz::echoError1('查询失败');
}
}
public function Del()
{
$id =request('id');
$d=DB::table('plan_model')->where(['id'=>$id])->update([
'is_del'=>1
]);
if($d){
return \Yz::Return(true,'操作完成',[]);
}else{
return \Yz::echoError1('操作失败');
}
}
}

@ -0,0 +1,103 @@
<?php
namespace App\Http\Controllers\API\Admin\YeWu;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class PlanTypeController extends Controller
{
public function Save()
{
$Info =request('Info');
$params = [
'name' => isset($Info['name']) ? $Info['name'] : null,
'is_vip' => isset($Info['is_vip']) ? $Info['is_vip'] : null,
'use_type' => isset($Info['use_type']) ? $Info['use_type'] : null,
'sex' => isset($Info['sex']) ? $Info['sex'] : null,
'checkup_type_id' => isset($Info['checkup_type_id']) ? json_encode($Info['checkup_type_id']) : null,
'amount_limit1' => isset($Info['amount_limit1']) ? $Info['amount_limit1'] : 0,
'amount_limit2' => isset($Info['amount_limit2']) ? $Info['amount_limit2'] : 0,
'status'=>isset($Info['status']) ? $Info['status'] : 0,
'color'=>isset($Info['color']) ? $Info['color'] : null,
];
$requiredFields = ['name'=>'名称','is_vip'=>'vip类型','use_type'=>'个检/团检类型','checkup_type_id'=>'体检类型','status'=>'状态','color'=>'颜色'];
// 判断是否为空
foreach ($requiredFields as $key=> $field) {
if (!isset($params[$key]) || $params[$key] === null) {
return \Yz::echoError1('参数 ' . $field . ' 不能为空');
}
}
$do=false;
$table=DB::table('plan_type');
if($Info['id']==0){
$do=$table->insert($params);
}
if($Info['id']>0){
$do=$table->where(['id'=>$Info['id']])->update($params);
}
if($do){
return \Yz::Return(true,'操作成功',[]);
}else{
return \Yz::echoError1('操作失败');
}
}
public function GetList()
{
$page =request('page');
$pageSize =request('pageSize');
$searchInfo=request('searchInfo');
$list=DB::table('plan_type')->where(['is_del'=>0]);
if(isset($searchInfo['name'])){
$list = $list->where('name', 'like','%'.$searchInfo['name'].'%');
}
if(isset($searchInfo['status'])){
$list = $list->where('status',$searchInfo['status']);
}
$count=$list->count();
if(isset($page) and isset($pageSize)){
$list=$list->orderBy('id', 'desc')->limit($pageSize)->skip(($page - 1) * $pageSize)->take($pageSize);
}
$list=$list ->get();
//匹配检查类型
$check=DB::table('checkup_type')->where(['is_del'=>0])->get();
foreach ($list as $key => $l){
$checkup_type_id=json_decode($l->checkup_type_id,true);
$CheckTypeName=[];
foreach($check as $k2=>$l2){
if(in_array($l2->id,$checkup_type_id)){
$CheckTypeName[]=$l2->name;
}
}
$l->check_type_name=$CheckTypeName;
}
return \Yz::Return(true,'查询完成',['list'=>$list,'count'=>$count]);
}
public function GetDetail()
{
$id =request('id');
$info=DB::table('plan_type')->where(['id'=>$id,'is_del'=>0])->first();
if(!!$info){
$info->checkup_type_id=json_decode($info->checkup_type_id,true);
return \Yz::Return(true,'查询完成',$info);
}else{
return \Yz::echoError1('查询失败');
}
}
public function Del()
{
$id =request('id');
$d=DB::table('plan_type')->where(['id'=>$id])->update([
'is_del'=>1
]);
if($d){
return \Yz::Return(true,'操作完成',[]);
}else{
return \Yz::echoError1('操作失败');
}
}
}

@ -0,0 +1,83 @@
<?php
namespace App\Http\Controllers\API\Admin\YeWu;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class QuestionController extends Controller
{
public function GetList()
{
$searchInfo = request('searchInfo');
if (!isset($searchInfo['hospital_id'])) return \Yz::echoError1("医院id不能为空");
if (!isset($searchInfo['q_type'])) return \Yz::echoError1("问卷类型不能为空");
$list = DB::table('questions')
->where(['hospital_id' => $searchInfo['hospital_id'],
'q_type' => $searchInfo['q_type'],
'is_del' => 0,
])->orderBy('order', 'asc')->get();
return \Yz::Return(true, "查询成功", ['list' => $list]);
}
public function Save()
{
$QuestionInfo = request('QuestionInfo');
$params = [
'hospital_id' => isset($QuestionInfo['hospital_id']) ? $QuestionInfo['hospital_id'] : null,
'question' => isset($QuestionInfo['question']) ? $QuestionInfo['question'] : null,
'content' => (isset($QuestionInfo['content']) and !empty($QuestionInfo['content'])) ? json_encode($QuestionInfo['content'], JSON_UNESCAPED_UNICODE) : null,
'type' => isset($QuestionInfo['type']) ? $QuestionInfo['type'] : null,
'status' => isset($QuestionInfo['status']) ? $QuestionInfo['status'] : null,
'order' => isset($QuestionInfo['order']) ? $QuestionInfo['order'] : null,
'q_type' => isset($QuestionInfo['q_type']) ? $QuestionInfo['q_type'] : null,
];
$requiredFields = [
'hospital_id', 'question', 'content', 'type', 'status', 'order', 'q_type'
];
// 判断是否为空
foreach ($requiredFields as $field) {
if (!isset($params[$field]) || $params[$field] === null) {
return \Yz::echoError1('参数' . $field . '不能为空');
}
}
if (isset($QuestionInfo['id']) and $QuestionInfo['id'] <> 0) {
$insert = DB::table('questions')->where(['id' => $QuestionInfo['id'], 'is_del' => 0])->update($params);
} else {
$insert = DB::table('questions')->insert($params);
}
if ($insert) {
return \Yz::Return(true, '操作成功', []);
} else {
return \Yz::echoError1('操作失败');
}
}
public function GetDetail()
{
$id = request('id');
$info = DB::table('questions')->where(['id' => $id, 'is_del' => 0])->first();
if (!!$info) {
$info->content = json_decode($info->content, true);
}
return \Yz::Return(true, '查询完成', $info);
}
public function Del()
{
$id = request('id');
$del = DB::table('questions')->where(['id' => $id])->update([
'is_del' => 1
]);
if ($del) {
return \Yz::Return(true, '操作成功', []);
} else {
return \Yz::echoError1('操作失败');
}
}
}

@ -0,0 +1,120 @@
<?php
namespace App\Http\Controllers\API\Admin\YeWu;
use App\Http\Controllers\Controller;
use App\Lib\Tools;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use PhpOffice\PhpSpreadsheet\IOFactory;
class QuestionLogController extends Controller
{
public function Export()
{
$q_type = request('q_type');
$dateRange = request('dateRange');
if(!isset($dateRange) or count($dateRange)<>2) return \Yz::echoError1("请选择日期");
$dateRange=[$dateRange[0].' 00:00:00',$dateRange[1].' 23:59:59'];
$q_list=DB::table('questions')->where(['q_type'=>2,'is_del'=>0,'status'=>1])->orderBy('order','asc')->get();
$log_list = DB::table('questions_log')->whereBetween('created_at',$dateRange)->where(['q_type' => $q_type])->get();
if(count($log_list)==0) return \Yz::echoError1("暂无数据可导出");
$cols_SN = $this->generateSequence(400);
$template_path = Storage::path('public/excel/manyidudiaocha.xlsx');
$spreadsheet = IOFactory::load($template_path);
$worksheet = $spreadsheet->getActiveSheet();
$styleArray = [
'borders' => [
'allBorders' => [
'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
'color' => ['argb' => 'FF000000'],
],
],
];
$row=3;
foreach ($log_list as $key=> $item) {
$personinfo=DB::table('web_user_person')->where(['id'=>$item->personid])->first();
$sex='未知';
if($personinfo->sex==1) $sex='男';
if($personinfo->sex==2) $sex='女';
$item->content=json_decode($item->content,true);
$worksheet->setCellValueExplicit($cols_SN[0] . $row, $key+1, \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
$worksheet->setCellValueExplicit($cols_SN[1] . $row, $personinfo->name, \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
$worksheet->setCellValueExplicit($cols_SN[2] . $row, $item->created_at, \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
$worksheet->setCellValueExplicit($cols_SN[3] . $row, $personinfo->name, \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
$worksheet->setCellValueExplicit($cols_SN[4] . $row, $personinfo->phone, \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
$worksheet->setCellValueExplicit($cols_SN[5] . $row, $sex, \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
$worksheet->setCellValueExplicit($cols_SN[6] . $row, $personinfo->birthday, \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
$worksheet->setCellValueExplicit($cols_SN[7] . $row, Tools::GetAge($personinfo->birthday), \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
foreach ( $item->content as $q_key=>$q_item){
foreach ($q_item['more'] as $morekey=>$moreitem){
if($moreitem<>null){
$q_item['answer'][0]=$q_item['answer'][0].','.$moreitem;
}
}
$worksheet->setCellValueExplicit($cols_SN[8+$q_key] . $row, $q_item['answer'][0], \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
}
$row++;
}
$worksheet->getStyle('A3:Z' . ($row - 1))->applyFromArray($styleArray);
$file_name = Str::orderedUuid();
$dir_path = "public/excel/" . date('Ym') . '/' . $file_name;
Storage::makeDirectory($dir_path);
//$name_date = date('n.j', strtotime($date . ' 00:00:00'));
$excel_path = $dir_path . "/满意度调查.xlsx";
$writer = new Xlsx($spreadsheet);
$writer->save(Storage::path($excel_path));
$url = Storage::url($excel_path);
return \Yz::Return(true,"获取成功",['url' => env('APP_URL').$url]);
}
function generateSequence($L) {
$sequence = [];
$current = '';
// Helper function to increment the sequence
function increment(&$str) {
$len = strlen($str);
$str = strrev($str); // Reverse string for easier manipulation
for ($i = 0; $i < $len; $i++) {
if ($str[$i] == 'Z') {
$str[$i] = 'A';
} else {
$str[$i] = chr(ord($str[$i]) + 1);
break;
}
}
// If we've gone through all characters and they were all 'Z'
if ($i == $len && $str[$len-1] == 'A') {
$str .= 'A'; // Append an 'A' at the end, equivalent to carrying over
}
$str = strrev($str); // Reverse back to original order
}
// Initialize the first value of the sequence
if ($L > 0) {
$current = 'A';
$sequence[] = $current;
}
// Generate the sequence up to length L
for ($i = 1; $i < $L; $i++) {
increment($current);
$sequence[] = $current;
}
return $sequence;
}
}

@ -0,0 +1,132 @@
<?php
namespace App\Http\Controllers\API\Admin\Yewu;
use App\Http\Controllers\API\PEISApiController;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class ReportController extends Controller
{
//获取思信那边的报告信息,推送或者拉取
public function ReportInfo()
{
$type = "la"; //la拉取 //tui 推送
$hospital_id = request('hospital_id');
$id_number = request('id_number');
$reports_detail_list = [];
$peis = new PEISApiController();
if ($type == 'la') {
$person = DB::table('web_user_person')->where(['id_number' => $id_number, 'is_del' => 0])->first();
if (!$person) return \Yz::echoError1('体检人不存在');
$data = [
'电话号码' => "",
'证件号码' => $id_number,
'体检号' => ""
];
$reports = $peis::Post('体检报告查询', $hospital_id, $data);
if (count($reports['data']) > 0) {
$reports_detail_list = $reports['data'];
}
}
//获取到报告列表后
foreach ($reports_detail_list as $key => $reports_detail) {
$data = [
'电话号码' => "",
'证件号码' => "",
'体检号' => $reports_detail['体检号']
];
$res = $peis::Post('体检报告查询', $hospital_id, $data);
$res = $res['data'][0];
//根据体检号查询获取id万一不小心有多个相同的体检号 所以返回数组正常就1个
$report_l1_records_ids = DB::table('report_l1_records')->where(['体检号' => $res['体检号']])->pluck('id')->toArray();
//查找对应的收费项目列表 获取id数组
$report_l2_items_ids = DB::table('report_l2_items')->whereIn('reprort_l1_id', $report_l1_records_ids)->pluck('id')->toArray();
//查找 基础项目列表 删除
$report_l3_base_items_del = DB::table('report_l3_base_items')->whereIn('report_l2_id', $report_l2_items_ids)->delete();
//删除report_l2_items表数据
DB::table('report_l2_items')->whereIn('id', $report_l2_items_ids)->delete();
//删除report_l1_records表数据
DB::table('report_l1_records')->whereIn('id', $report_l1_records_ids)->delete();
//删除完后,进行添加
$r_data = [
"体检类型" => isset($res['体检类型']) ? $res['体检类型'] : null,
"查询密码" => isset($res['查询密码']) ? $res['查询密码'] : null,
"审核时间" => isset($res['审核时间']) ? $res['审核时间'] : null,
"总检医生" => isset($res['总检医生']) ? $res['总检医生'] : null,
"总检结论" => isset($res['总检结论']) ? $res['总检结论'] : null,
"总检建议" => isset($res['总检建议']) ? $res['总检建议'] : null,
"病种列表" => isset($res['病种列表']) ? json_encode($res['病种列表'], JSON_UNESCAPED_UNICODE) : null,
"报告文件列表" => isset($res['报告文件列表']) ? json_encode($res['报告文件列表'], JSON_UNESCAPED_UNICODE) : null,
"卡号" => $res['卡号'],
"证件类型" => $res['证件类型'],
"证件号码" => $res['证件号码'],
"地址" => $res['地址'],
"电话号码" => $res['电话号码'],
"婚姻状态" => $res['婚姻状态'],
"单位名称" => $res['单位名称'],
"批次Id" => $res['批次Id'],
"批次名称" => $res['批次名称'],
"部门名称" => $res['部门名称'],
"分组名称" => $res['分组名称'],
"体检号" => $res['体检号'],
"姓名" => $res['姓名'],
"性别" => $res['性别'],
"出生日期" => $res['出生日期'],
"登记时间" => $res['登记时间'],
"检前签到时间" => $res['检前签到时间'],
"体检状态" => $res['体检状态'],
"报告日期" => $res['报告日期'],
"套餐名称" => $res['套餐名称'],
"团检" => $res['团检'],
"支持下载报告文件" => $res['支持下载报告文件'],
];
$l1_id = DB::table('report_l1_records')->insertGetId($r_data);
if ($res['体检状态'] == '报告已出') {
foreach ($res['收费项目列表'] as $key => $l2_item) {
$r2_data = [
"reprort_l1_id" => $l1_id,
"科室类型" => $l2_item['科室类型'],
"科室名称" => $l2_item['科室名称'],
"科室顺序" => $l2_item['科室顺序'],
"收费项目名称" => $l2_item['收费项目名称'],
"收费项目顺序" => $l2_item['收费项目顺序'],
"检查医生" => $l2_item['检查医生'],
"审核医生" => $l2_item['审核医生'],
"最后保存时间" => $l2_item['最后保存时间'],
];
$l2_id = DB::table('report_l2_items')->insertGetId($r2_data);
if ($l2_id) {
$report_l3_base_items = [];
foreach ($l2_item['基础项目列表'] as $key2 => $l3_item) {
$r3_data = [
"report_l2_id" => $l2_id,
"基础项目名称" => $l3_item['基础项目名称'],
"基础项目代码" => $l3_item['基础项目代码'],
"基础项目顺序" => $l3_item['基础项目顺序'],
"结果类型" => $l3_item['结果类型'],
"结果值" => $l3_item['结果值'],
"结果值单位" => $l3_item['结果值单位'],
"结果值范围" => $l3_item['结果值范围'],
"异常标识" => $l3_item['异常标识'],
"所见" => $l3_item['所见'],
"描述" => $l3_item['描述'],
"结论" => $l3_item['结论'],
];
$report_l3_base_items[] = $r3_data;
}
//批量插入l3
DB::table('report_l3_base_items')->insert($report_l3_base_items);
}
}
}
}
return \Yz::Return(true, "操作完成", []);
}
}

@ -0,0 +1,51 @@
<?php
namespace App\Http\Controllers\API\Admin\YeWu;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class YuYueOrderController extends Controller
{
public function GetList()
{
$page = request('page');
$pageSize = request('pageSize');
$searchInfo = request('searchInfo');
$list=DB::table('orders_yuyue');
if(isset($searchInfo['name'])){
$list = $list->where('name', 'like', '%' . $searchInfo['name'] . '%');
}
if(isset($searchInfo['id_number'])){
$list = $list->where('id_number', $searchInfo['id_number'] );
}
if(isset($searchInfo['order_number'])){
$list = $list->where('order_number', $searchInfo['order_number'] );
}
$count=$list->count();
$list=$list->orderBy('id','desc')
->skip(($page-1)*$pageSize) // 跳过前9999条记录
->take($pageSize)->get();
return \Yz::Return(true,"查询完成",['list'=>$list,'count'=>$count]);
}
public function GetDetail()
{
$id = request('id');
$order=DB::table('orders_yuyue')->where(['id'=>$id])->first();
return \Yz::Return(true,"查询完成",['info'=>$order]);
}
public function Save()
{
$info = request('info');
$date=[
'note'=>$info['note']
];
$u=DB::table('orders_yuyue')->where(['id'=>$info['id']])->update($date);
if($u){
return \Yz::Return(true,"操作完成",[]);
}else{
return \Yz::echoError1("保存失败");
}
}
}

@ -0,0 +1,47 @@
<?php
namespace App\Http\Controllers\API\Admin\YeWu;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Services\Admin\YeWu\HealthCalendarService;
class healthCalendarController extends Controller
{
public function getList(Request $request){
$userid = $request->get('userid');//中间件产生的参数
$group = $request->get('role');//中间件产生的参数
$page =request('page');
$pageSize =request('pageSize');
$searchInfo=request('searchInfo');
$s=app()->make(HealthCalendarService::class);
return $s->getList(['group'=>$group,'userid'=>$userid,'page'=>$page,'pageSize'=>$pageSize,'searchInfo'=>$searchInfo]);
}
//创建日历
public function CreateCalendar(Request $request){
$userid = $request->get('userid');//中间件产生的参数
$group = $request->get('role');//中间件产生的参数
$info= request('info');
if($group<>1 and $group<>7) return \Yz::echoError('无此接口访问权限');
$s=app()->make(HealthCalendarService::class);
return $s->CreateCalendar(['info'=>$info,'group'=>$group,'userid'=>$userid]);
}
public function Del(Request $request){
$userid = $request->get('userid');//中间件产生的参数
$group = $request->get('role');//中间件产生的参数
$list= request('list');
$s=app()->make(HealthCalendarService::class);
return $s->Del(['list'=>$list,'group'=>$group,'userid'=>$userid]);
}
//修改日历信息
public function ChangeInfo(Request $request){
$userid = $request->get('userid');//中间件产生的参数
$group = $request->get('role');//中间件产生的参数
$changeInfo= request('changeInfo');
$s=app()->make(HealthCalendarService::class);
return $s->ChangeInfo(['changeInfo'=>$changeInfo,'group'=>$group,'userid'=>$userid]);
}
}

@ -0,0 +1,119 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use App\Services\ConfigService;
use Illuminate\Http\Request;
class ApiMapController extends Controller
{
//获取站点配置信息
public function h5()
{
$base_url = env('APP_URL');
return [];
}
//获取站点配置信息
public function public()
{
$base_url = env('APP_URL');
return [
'OrderList' => $base_url . '/api/H5/Order/list',
'ComboList' => $base_url . '/api/H5/Combo/list',
'ComboSelect' => $base_url . '/api/H5/Combo/select',
'UserInfo' => $base_url . '/api/H5/User/info',
'ConfigVersion' => $base_url . '/api/H5/Config/version',
'ConfigConfig' => $base_url . '/api/H5/Config/config',
'DemoPay' => $base_url . '/api/Demo/pay',
'ApiMapTest' => $base_url . '/api/ApiMap/test',
'CheckUpTypeGetList' => $base_url . '/api/H5/CheckUpTypeGetList',
'GetPersonList' => $base_url . '/api/H5/GetPersonList',
'SetDefaultPerson' => $base_url . '/api/H5/SetDefaultPerson',
'GetGeJianButtonList' => $base_url . '/api/H5/GetGeJianButtonList',
'ArticleGetList' => $base_url . '/api/H5/ArticleGetList',
'ArticleGetDetail' => $base_url . '/api/H5/ArticleGetDetail',
'GetAllItems' => $base_url . '/api/H5/GetAllItems', //获取全部自选项目
'BuyInfo' => $base_url . '/api/H5/BuyInfo', //获取全部自选项目
'GetComboSort' => $base_url . '/api/H5/GetComboSort', //套餐排序、筛选标签
'GetPersonIntegralSaveMoneyCouponInfo' => $base_url . '/api/H5/GetPersonIntegralSaveMoneyCouponInfo', //获取就诊人基本信息和预存款、代金券、积分
'DoctorGetList' => $base_url . '/api/H5/DoctorGetList', //获取体检医生列表
'ComboRecommend' => $base_url . '/api/H5/ComboRecommend', //套餐推荐
'GetReadme' => $base_url . '/api/H5/GetReadme', //须知
'NMRGetMonthPlanCount' => $base_url . '/api/H5/NMRGetMonthPlanCount', //核磁每日号源
'NMRGetDayPlanList' => $base_url . '/api/H5/NMRGetDayPlanList', //核磁每日号源
'GetGroupUnit' => $base_url . '/api/H5/GetGroupUnit', //团检登记查询获取单位分组
'GetGroupCombo' => $base_url . '/api/H5/GetGroupCombo', //获取团检套餐
'OrderCreate' => $base_url . '/api/H5/OrderCreate', //创建订单
'GetReportList' => $base_url . '/api/H5/GetReportList', //获取关联的所有体检人报告列表
'GetReportJieLunJianYi' => $base_url . '/api/H5/GetReportJieLunJianYi', //获取报告结论建议页面数据
'GetReportDetaiList' => $base_url . '/api/H5/GetReportDetaiList', //完整报告中的列表
'GetReportDetai' => $base_url . '/api/H5/GetReportDetai', //完整报告中的详情
'StartPay' => $base_url . '/api/H5/StartPay', //开始支付
'CheckPay' => $base_url . '/api/H5/CheckPay', //支付查询
'Refund' => $base_url . '/api/H5/Refund', //退款
'GetMonthPlanCount' => $base_url . '/api/H5/GetMonthPlanCount', //按月获取每日号源
'GetDayPlanList' => $base_url . '/api/H5/GetDayPlanList', //获取每日号源
'ComboCompare' => $base_url . '/api/H5/ComboCompare', //套餐对比
'GetOrderDetail' => $base_url . '/api/H5/GetOrderDetail', //获取订单详情
'ReportContrast' => $base_url . '/api/H5/ReportContrast', //报告对比
'QuestionGetList' => $base_url . '/api/H5/QuestionGetList', //获取问卷
'QuestionSubmitAnswer' => $base_url . '/api/H5/QuestionSubmitAnswer', //提交问卷回答
'AnalysisTypeGetList' => $base_url . '/api/H5/AnalysisTypeGetList', //趋势分析项目列表
'ReportAnalysis' => $base_url . '/api/H5/ReportAnalysis', //报告趋势详情
'HunQianQuestionSubmit' => $base_url . '/api/H5/HunQianQuestionSubmit', //婚前问卷提交
'ChangeAppointment' => $base_url . '/api/H5/ChangeAppointment', //改约
'UsableIntegralSaveMoney' => $base_url . '/api/H5/UsableIntegralSaveMoney', //获取本单可用金额和积分
'FenzhenAbandon' => $base_url . '/api/H5/Fenzhen/abandon', // 分诊弃检
'FenzhenList' => $base_url . '/api/H5/Fenzhen/list', // 分诊时间线
'FenzhenInfo' => $base_url . '/api/H5/Fenzhen/info', // 分诊项目详情
'FenzhenCheck' => $base_url . '/api/H5/Fenzhen/check', // 分诊检测
'QuestionGet' => $base_url . '/api/H5/Question/get', // 问卷调查
'QuestionSubmit' => $base_url . '/api/H5/Question/submit', // 问卷提交
'QuestionLogInfo' => $base_url . '/api/H5/QuestionLog/info', // 提交信息
'QuestionLogList' => $base_url . '/api/H5/QuestionLog/list', // 问卷列表
'QuestionLogDelete' => $base_url . '/api/H5/QuestionLog/delete', // 问卷删除记录
'QuestionLogPush' => $base_url . '/api/H5/QuestionLog/push', // 上次答题记录
'QuestionChoose' => $base_url . '/api/H5/Question/choose', // 健康问卷列表
'AddressData' => $base_url . '/api/H5/Address/data', // 省市区数据
'UserHunjian' => $base_url . '/api/H5/User/hunjian', // 婚检人员信息
'hunjianBySFZ' => $base_url . '/api/H5/hunjianBySFZ', // 婚检人员信息
'CheckedSignIn' => $base_url . '/api/H5/CheckedSignIn', // 检后签到
'SendMsgCode' => $base_url . '/api/H5/SendMsgCode', // 发送验证码
'CheckMsgCode' => $base_url . '/api/H5/CheckMsgCode', // 验证验证码
];
}
public function address()
{
$address_data = file_get_contents(public_path('assets/address.json'));
return \Yz::Return(true, '获取成功', [
'data' => json_decode($address_data, true)
]);
}
public function test()
{
return \Yz::Return(true, '获取成功', [
'name' => env('APP_NAME'),
'datetime' => date('Y-m-d H:i:s'),
]);
}
public function list($type)
{
$list = self::public();
switch ($type) {
case 'h5':
$list = array_merge($list, self::h5());
break;
}
return \Yz::Return(true, '获取成功', [
'list' => $list
]);
}
}

@ -0,0 +1,255 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Http\Exceptions\HttpResponseException;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Schema;
class AspNetZhuanController extends Controller
{
public static $request;
public static $BaseUrl = "http://220.174.210.111:82";//url
public static $JF_BaseUrl = "http://220.174.210.111:82/jifen.aspx";//积分预存款Url
//获取用户积分和预存款
public static function GetJiFen_YuCunKuan($type, $ghzid)
{
$res = self::Get(self::$JF_BaseUrl . '?type=' . $type . '&ghzid=' . $ghzid,"查询剩余积分/预存款");
if ($type == 1) return $res['剩余积分'];
if ($type == 2) return $res['剩余预存款'];
}
//获取本次账单可使用的积分
public static function GetEnableCount($ghzid,$ysje,$ssje)
{
$res = self::Get(self::$JF_BaseUrl . '?type=3' . '&ghzid=' . $ghzid. '&ysje=' . $ysje. '&ssje=' . $ssje,"查询本单积分");
return $res['本次账单可抵扣积分'];
}
//使用积分
public static function UseJiFen($ghzid,$jifen,$yyid,$caozuorenid,$caozuorenmigncheng,$beizhu,$dingdanshijian){
$res = self::Get(self::$JF_BaseUrl . '?type=4' . '&ghzid=' . $ghzid. '&jifen=' . $jifen.'&yyid='.$yyid.'&caozuorenid='.$caozuorenid.'&caozuorenmigncheng='.urlencode($caozuorenmigncheng).'&beizhu='.urlencode($beizhu).'&dingdanshijian='.urlencode($dingdanshijian),"积分变更");
return true;
}
//使用预存款
public static function UseYuCunKuan($ghzid,$yucunkuan,$yyid,$yucunkuanleixing,$caozuorenid,$caozuorenmigncheng,$beizhu,$dingdanshijian)
{
$res = self::Get(self::$JF_BaseUrl . '?type=5' . '&ghzid=' . $ghzid. '&yucunkuan=' . $yucunkuan.'&yyid='.$yyid.'&yucunkuanleixing='.$yucunkuanleixing.'&caozuorenid='.$caozuorenid.'&caozuorenmigncheng='.urlencode($caozuorenmigncheng).'&beizhu='.urlencode($beizhu).'&dingdanshijian='.urlencode($dingdanshijian),"预存款变更");
return true;
}
//二线预约
public static function ErXian($data,$nonce)
{
// $res= self::Post(self::$BaseUrl . '/erxianzhongzhuan.aspx?str='.$nonce,$data,'二线号源');
$res= self::Post(self::$BaseUrl . '/erxian.aspx?str='.$nonce,$data,'二线号源');
if($data['action']==2) return $res['gid']??false;
return $res['data']??true;
}
//发送短信
public static function SendMsg($r_yyid,$tel,$name,$time,$sex){
$yy_name='';
if($r_yyid==1){
$yyid=6;
$yy_name="现代妇儿秀英院区";
}
if($r_yyid==4){
$yyid=2;
$yy_name="现代妇儿府城院区";
}
$keshi="健康管理中心1区";
if($sex==1) $keshi="健康管理中心1楼男宾区";
if($sex==2) $keshi="健康管理中心2楼女宾区";
$sex_zh='';
if($sex==1) $sex_zh="先生";
if($sex==2) $sex_zh="女士";
//$content="时间:".$time.";科室:".$keshi."。温馨提醒:您的预约已成功,请在预约时间前 30 分钟达到科室凭身份证原件开单。建议您体检前3天清淡饮食、禁烟酒";
$content=$time." 健康体检。请提前10分钟凭身份证到".$yy_name.$keshi."签到。建议体检前3天清淡饮食、禁烟酒。体检当天需禁食禁水空腹6小时以上";
$url=self::$BaseUrl."/tuisong.aspx?yyid=".$yyid."&type=8&mobile=".$tel."&msg1=".urlencode($name)."&msg2=".urlencode($content);
self::get($url,"短信发送");
}
//发送验证码
public static function SendYanZhengMaCode($r_yyid,$tel,$code){
if($r_yyid==1){
$yyid=6;
$yy_name="现代妇儿秀英院区";
}
if($r_yyid==4){
$yyid=2;
$yy_name="现代妇儿府城院区";
}
$url=self::$BaseUrl."/tuisong.aspx?yyid=".$yyid."&type=13&mobile=".$tel."&msg1=".urlencode($code);
self::get($url,"短信发送");
}
//获取优惠卷类型
public static function YouHuiQuan($data)
{
$nonce=uniqid();
//$res= self::Post(self::$BaseUrl . '/zhongzhuan.aspx?str='.$nonce,$data,'获取优惠卷类型');
$res= self::Post(self::$BaseUrl . '/youhuijuan.aspx?str='.$nonce,$data,'获取优惠卷类型');
return $res['data']??true;
}
//获取人员档案
public static function GetPersonInfo($data)
{
$res= self::Post(self::$BaseUrl . '/renyuan.aspx',$data,'获取人员档案');
if($data['action']==2) return $res;
return $res['data'] ?? false;
}
//获取报告解读日期和状态
public static function GetReportAnalysis($data)
{
$res= self::Post2(self::$BaseUrl . '/baogaojiedu.aspx',$data,'报告解读');
return $res;
}
//获取指定日期医生排班
public static function GetDoctorDateList($data)
{
$res= self::Post2(self::$BaseUrl . '/yisheng.aspx',$data,'医生排班');
return $res;
}
//微信推送
public static function WeiXinSend($data)
{
$nonce=uniqid();
$res= self::Post(self::$BaseUrl . '/sendwx.aspx?str='.$nonce,$data,'微信推送');
return $res;
}
public static function Get($url,$mark)
{
self::RequestLog($url, [], $mark, '.Net转发');
$response = Http::get($url);
if($mark=="短信发送"){
Log::info( $response->body());
return true;
}
if ($response->successful()) {
$res = $response->json();
self::$request->response_data = json_encode($res, JSON_UNESCAPED_UNICODE);
self::$request->save();
if ($res['code'] == "200") {
return $res;
} else {
throw new HttpResponseException(\Yz::echoError1("调用".$mark."接口失败:" . $res['msg']));
}
} else {
$status = $response->status();
// 获取响应体作为字符串
$body = $response->body();
self::$request->response_data = $body;
self::$request->save();
throw new HttpResponseException(\Yz::echoError1("调用".$mark."接口失败:" . $status . "body:" . $body));
}
}
public static function Post($url,$data,$mark)
{
self::RequestLog($url, $data, $mark, '.Net转发');
$response = Http::post($url,$data);
if ($response->successful()) {
$res = $response->json();
$res_string=json_encode($res, JSON_UNESCAPED_UNICODE);
$str_len = mb_strlen($res_string, 'utf-8');
$str_size = $str_len / 1024;
$save_res = $res_string;
if ($str_size > 10) $save_res = '{"data":"Row size too large"}';
self::$request->response_data = $save_res;
self::$request->save();
if (strpos($url, "renyuan.aspx") !== false and $data['action']==2) {
return $res;
}
if ($res['code'] == "200") {
return $res;
} else {
throw new HttpResponseException(\Yz::echoError1("调用".$mark."接口失败:" . $res['msg']));
}
} else {
$status = $response->status();
// 获取响应体作为字符串
$body = $response->body();
self::$request->response_data = $body;
self::$request->save();
throw new HttpResponseException(\Yz::echoError1("调用".$mark."接口失败:" . $status . "body:" . $body));
}
}
public static function Post2($url,$data,$mark)
{
self::RequestLog($url, $data, $mark, '.Net转发');
$response = Http::post($url,$data);
if ($response->successful()) {
$res = $response->json();
$res_string=json_encode($res, JSON_UNESCAPED_UNICODE);
$str_len = mb_strlen($res_string, 'utf-8');
$str_size = $str_len / 1024;
$save_res = $res_string;
if ($str_size > 10) $save_res = '{"data":"Row size too large"}';
self::$request->response_data = $save_res;
self::$request->save();
return $res;
} else {
$status = $response->status();
// 获取响应体作为字符串
$body = $response->body();
self::$request->response_data = $body;
self::$request->save();
throw new HttpResponseException(\Yz::echoError1("调用".$mark."接口失败:" . $status . "body:" . $body));
}
}
public static function RequestLog($url, $post_data, $mark, $code = 0)
{
self::CheckTableName();
foreach ($post_data as $key => $post_datum) {
$str_len = mb_strlen(json_encode($post_datum, JSON_UNESCAPED_UNICODE), 'utf-8');
$str_size = $str_len / 1024;
if ($str_size > 10) {
$post_data["$key"] = 'Row size too large';
}
}
$post_data = json_encode($post_data, JSON_UNESCAPED_UNICODE);
self::$request->code = $code;
self::$request->mark = $mark;
self::$request->post_data = $post_data == '[]' ? '{}' : $post_data;
self::$request->request_url = $url;
self::$request->save();
}
public static function CheckTableName()
{
$table_name = 'zz_peis_log_' . date('ym');
$table_count = DB::select('select count(1) as c from information_schema.TABLES where table_schema = ? and table_name = ?', [env('DB_DATABASE'), $table_name])[0];
if ($table_count->c === 0) {
Schema::create($table_name, function (Blueprint $table) {
$table->id();
$table->string('code', 50)->index();
$table->string('mark', 50)->index();
$table->text('post_data');
$table->text('response_data')->nullable();
$table->string('request_url', 2000);
$table->timestamps();
});
}
self::$request = new \App\Models\PEISLog();
self::$request->setTable($table_name);
}
}

@ -0,0 +1,47 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use App\Http\Controllers\API\WeChatPayController;
use Illuminate\Http\Request;
class DemoController extends Controller
{
public function pay_back()
{
$input = file_get_contents('php://input');
file_put_contents(base_path() . '/storage/app/pay/pay_back.txt', urldecode($input));
return [
'code' => 'SUCCESS',
'message' => '成功',
];
}
public function pay(Request $request)
{
$openid = $request->post('openid');
$total = $request->post('total');
$wcp = new WeChatPayController();
$wcp->builder([
'appid' => 'wx0d92d2990ec16a55',
'pem_path' => base_path() . '/storage/app/pay/key.pem',
'cer_path' => base_path() . '/storage/app/pay/crt.pem',
'cer_num' => '3CE37188EBCFBBEB800B0E1C69B360F05A3E80CD',
'mchid' => '1638739772',
'v3' => 'AVPV7NxK8cC2RvRrrwdTqUG9YbQXQe3w',
]);
$out_trade_no = date('Ymd') . time() . rand(10, 99);
$pay = $wcp->create([
'description' => '体检预约',
'out_trade_no' => $out_trade_no,
'notify_url' => 'https://api.hainan2024.sa0.online/api/Demo/pay_back',
'total' => $total,
'openid' => $openid
]);
return \Yz::Return(true, '获取成功', [
'pay' => $pay
]);
}
}

@ -0,0 +1,32 @@
<?php
namespace App\Http\Controllers\API\H5;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class AnalysisTypeController extends Controller
{
public function GetList(Request $request)
{
$analysis_type_list = DB::table('analysis_types')->where('status', 1)->get();
$analysis_list = [[
'title' => '临床生化',
'list' => [],
], [
'title' => '临床免疫',
'list' => [],
], [
'title' => '常规',
'list' => [],
]];
foreach ($analysis_type_list as $item) {
$analysis_list[$item->type - 1]['list'][] = $item;
}
return \Yz::return(true,"查询完成",['list' => $analysis_list]);
}
}

@ -0,0 +1,31 @@
<?php
namespace App\Http\Controllers\API\H5;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class ArticleController extends Controller
{
//获取列表
public function GetList()
{
$type=request('type');
$list = DB::table('articles')->select('id','type','title')->where(['type'=>$type,'is_del'=>0,'status'=>1])->orderBy('order','asc')->get();
return \Yz::Return(true,"查询完成",['list'=>$list]);
}
//获取详情
public function GetDetail()
{
$id=request('id');
$info = DB::table('articles')->select('id','type','title','content')->where(['id'=>$id,'is_del'=>0,'status'=>1])->first();
if($info){
return \Yz::Return(true,"查询完成",['info'=>$info]);
}else{
return \Yz::echoError1("文章内容查询失败");
}
}
}

@ -0,0 +1,17 @@
<?php
namespace App\Http\Controllers\API\H5;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class CheckUpTypeController extends Controller
{
//H5获取体检类型名称和logo
public function GetList()
{
$list=DB::table('checkup_type')->where(['status'=>1,'is_del'=>0])->get();
return \Yz::Return(true,"查询完成",['list'=>$list]);
}
}

@ -0,0 +1,834 @@
<?php
namespace App\Http\Controllers\API\H5;
use App\Http\Controllers\API\AspNetZhuanController;
use App\Http\Controllers\Controller;
use App\Services\ConfigService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class ComboController extends Controller
{
public function select(Request $request)
{
$combo = DB::table('combo_type')->select('id as value', 'name as label')->get();
$person = DB::table('combo_crowd')->select('id as value', 'name as label')->get();
// $combo = [[
// 'label' => '类型一',
// 'value' => '1',
// ], [
// 'label' => '类型二',
// 'value' => '2',
// ]];
// $person = [[
// 'label' => '类型一',
// 'value' => '1',
// ], [
// 'label' => '类型二',
// 'value' => '2',
// ]];
return \Yz::Return(true, '获取成功', [
'combo' => $combo,
'person' => $person
]);
}
public function list(Request $request)
{
$hospital = $request->post('hospital');
$doctor = $request->post('doctor');
$openid = $request->post('openid');
$search = $request->post('search');
$combo_sort = $request->post('combo_sort');
$combo_type = $request->post('combo_type');
$combo_crowd = $request->post('combo_crowd');
$combo_price = $request->post('combo_price');
$combo_item = $request->post('combo_item');
$checkup_type_id = $request->post('checkup_type_id');
$keshi_name=$request->post('keshi_name');
$price_range=$request->post('price_range');
$sort_price=$request->post('sort_price');
$sort_sale_count=$request->post('sort_sale_count');
$hospital = DB::table('hospitals')->select('id', 'name', 'address', 'latitude', 'longitude')->where(['id' => $hospital])->first();
$user = DB::table('web_users')->where(['openid' => $openid, 'status' => 1, 'is_del' => 0])->first();
if (!$user) return \Yz::echoError1('openid对应用户不存在');
$person = DB::table('web_user_person')->where(['user_id' => $user->id, 'is_del' => 0, 'is_default' => 1])->first();
if (!$person) return \Yz::echoError1("请选择就诊人");
//用户绑定就诊人数量
$personCount = DB::table('web_user_person')->where(['user_id' => $user->id, 'is_del' => 0])->count();
$canshu = [];
$canshu[]=$person->sex;
$sql = '';
if (isset($combo_price) and !isset($price_range)) {
$price_list = [
"1" => [0, 299],
"2" => [300, 999],
"3" => [1000, 1499],
"4" => [1500, 2999],
"5" => [3000, 999999],
];
$sql = " and (a.price>=? and a.price<=?) ";
$canshu[] = $price_list[$combo_price][0];
$canshu[] = $price_list[$combo_price][1];
}
if (isset($price_range) and !isset($combo_price)) {
$sql = " and (a.price>=? and a.price<=?) ";
$canshu[] = $price_range[0];
$canshu[] = $price_range[1];
}
if(isset($checkup_type_id)){
$sql = $sql . " and a.checkup_type_id=? ";
$canshu[] = $checkup_type_id;
}else{
$sql = $sql . " and a.checkup_type_id<>4 ";
}
if (isset($combo_type)) {
$sql = $sql . " and a.type_id=? ";
$canshu[] = $combo_type;
}
if (isset($combo_crowd)) {
$sql = $sql . " and a.crowd_id=? ";
$canshu[] = $combo_crowd;
}
if(isset($search) and !empty($search)){
$sql = $sql . " and a.name like ? ";
$canshu[] = '%'.$search.'%';
}
if(isset($sort_price) and $sort_price==1) $combo_sort=3;
if(isset($sort_price) and $sort_price==2) $combo_sort=4;
if(isset($sort_sale_count) and $sort_sale_count==1) $combo_sort=7;
if(isset($sort_sale_count) and $sort_sale_count==2) $combo_sort=8;
if (isset($combo_sort)) {
if ($combo_sort == 1) {
$sql = $sql . " ";
}
if ($combo_sort == 2) {
$sql = $sql . " order by a.sale_count desc";
}
if ($combo_sort == 3) {
$sql = $sql . " order by a.price";
}
if ($combo_sort == 4) {
$sql = $sql . " order by a.price desc";
}
if ($combo_sort == 5) {
$sql = $sql . " order by b.count desc";
}
if ($combo_sort == 6) {
$sql = $sql . " order by b.count ";
}
if ($combo_sort == 7) {
$sql = $sql . " order by a.sale_count ";
}
if ($combo_sort == 8) {
$sql = $sql . " order by a.sale_count desc";
}
}
if (!isset($combo_sort)) {
$sql = $sql . " order by a.order ";
}
if(isset($keshi_name)){
$combo_ids=DB::table('combo_items')->where(['status'=>1,'keshi_name'=>$keshi_name]) ->pluck('combo_id')->toArray();
$count = count($combo_ids);
$placeholders = implode(', ', array_fill(0, $count, '?'));
if(count($combo_ids)>0){
$sql = $sql . " and a.combo_id in ($placeholders) ";
$canshu =array_merge($canshu, $combo_ids);
}else{
$sql = $sql . " and a.combo_id in (?) ";
$canshu =array_merge($canshu, [0]);
}
}
if(isset($combo_item)){
$combo_ids=DB::table('combo_items')->whereIn('item_id',$combo_item)->where(['status'=>1])
->groupBy('combo_id')
->havingRaw('COUNT(DISTINCT item_id) = '.count($combo_item))
->pluck('combo_id')->toArray();
$count = count($combo_ids);
$placeholders = implode(', ', array_fill(0, $count, '?'));
if(count($combo_ids)>0){
$sql = $sql . " and a.combo_id in ($placeholders) ";
$canshu =array_merge($canshu, $combo_ids);
}else{
$sql = $sql . " and a.combo_id in (?) ";
$canshu =array_merge($canshu, [0]);
}
}
$combos = DB::select("select * from combos as a LEFT JOIN (
select combo_id as c_id,count(*) as count from combo_items where status in(1) group by combo_id
) as b on a.combo_id=b.c_id where a.status=1 and a.sex in(?,0) " . $sql ." ", $canshu);
foreach ($combos as $key => $combo) {
$combo->count=$combo->count?$combo->count:0;
$tags = json_decode($combo->tags, true);
$combo->tags2 = json_decode($combo->tags2, true);
foreach ($tags as $k => $tag) {
$tags[$k] = ['text' => $tag,
'text_color' => '#47ABD8',
'color' => '#EBF5FC'
];
}
$combo->tag = $tags;
$combo->tag[] = [
'text' => $combo->item_count . '个项目',
'text_color' => '#34C292',
'color' => '#E9F8F3',
];
//多选一
$duo_xuan_yi=[];
if(json_decode($combo->duo_xuan_yi)){
$N1=json_decode($combo->duo_xuan_yi);
foreach ($N1 as $k=>$v){
$duo_xuan_yi[$k][]=[
'zu_name'=>$v->组名称,
'item_list'=>[]
];
foreach ($v->包含项目 as $k2=>$v2){
$duo_xuan_yi[$k]['item_list'][]=
[
'item_id' =>$v2->Id,
'item_name' => $v2->名称,
'price'=>$v2->价格
];
}
}
}
$combo->duo_xuan_yi =$duo_xuan_yi;
}
$hospital_info = $hospital;
$info = [
'name' => $person->name,
'sex' => $person->sex,
'count' => $personCount
];
$doctor_info = [
'id' => $doctor,
'name' => '张大夫'
];
//获取套餐价格分布
$step = 500;
$maxPrice = 20000 + $step;
$result=DB::select("SELECT FLOOR(price / ?) * ? AS price_range_start, COUNT(*) AS count
FROM combos
WHERE price >= 0 AND price < ?
GROUP BY price_range_start;",[$step,$step,$maxPrice]);
$price_ranges = [];
for ($i = 0; $i <= 20000; $i += $step) {
$price_ranges[$i] = 0;
}
foreach ($result as $row) {
if (isset($price_ranges[$row->price_range_start])) {
$price_ranges[$row->price_range_start] = $row->count;
}
}
$formatted_price_ranges = [];
$formatted_price_ranges[]=['start' => 0,
'count' => 0];
foreach ($price_ranges as $start => $count) {
// 如果你想包括结束值,可以添加 'end' 键,例如:'end' => $start + 99
$formatted_price_ranges[] = [
'start' => $start,
'count' => $count
];
}
$price_max_min=DB::select("SELECT
MAX(price) AS highest_price,
MIN(price) AS lowest_price
FROM combos;");
return \Yz::Return(true, '获取成功', [
'list' => $combos,
'hospital' => $hospital_info,
'doctor' => $doctor_info,
'info' => $info,
'price_range' => $formatted_price_ranges,
'price_max_min' =>isset($price_range)?$price_range:[0,$maxPrice],
'price_max' =>$maxPrice,
'step' => $step,
]);
}
//获取套餐类型、适用人群
public function GetComboSort()
{
$type = DB::table('combo_type')->get();
$crowd = DB::table('combo_crowd')->get();
$sort_list = [
["id" => 1, 'name' => '综合排序'],
["id" => 2, 'name' => '销售最多'],
["id" => 3, 'name' => '低价优先'],
["id" => 4, 'name' => '高价优先'],
["id" => 5, 'name' => '项目最多'],
["id" => 6, 'name' => '项目最少'],
];
$price_list = [
['name' => '300以下', 'id' => 1],
['name' => '300-1000', 'id' => 2],
['name' => '1000-1500', 'id' => 3],
['name' => '1500-3000', 'id' => 4],
['name' => '3000以上', 'id' => 5],
];
$item_label = [
["id" => 3468454, 'name' => '内科检查'],
["id" => 1812, 'name' => '尿常规'],
["id" => 1955, 'name' => '肝功能'],
["id" => 1958, 'name' => '肾功能'],
];
return \Yz::Return(true, "查询成功", ['sort_list' => $sort_list, 'combo_type' => $type, 'combo_crowd' => $crowd, 'combo_price' => $price_list, 'combo_item' => $item_label]);
}
//获取购买详情内容(详情页信息)
public function BuyInfo()
{
$hospital_id = request('hospital');
$combo_id = request('combo_id'); //购买的套餐id
$item_ids = request('item_ids'); //自选项目ids
$duo_xuan_yi = request('duo_xuan_yi'); //多选1
$group_id = request('group_id'); //团检登记id
$wj_flag= request('wj'); //问卷标记
$coupon_id=request('coupon_id'); //代金券id
$person_id = request('person_id'); //就诊人id
$person=DB::table('web_user_person')->where(['id' => $person_id,'is_del'=>0])->first();
if(!$person) return \Yz::echoError1("用户不存在");
if (!isset($hospital_id)) return \Yz::echoError1("医院id不能为空");
$hospital = DB::table('hospitals')->where(['id' => 1, 'status' => 1, 'is_del' => 0])->first();
if(isset($wj_flag) and $wj_flag==1){
$wj_zhekou=config('app.globals.Wj_ZheKou');//问卷过来的折扣率
}
$combo_info = false;//套餐信息
$pay_item_count = 0;//需自费项目个数
$all_original_price = 0;
$true_price = 0;
$nmr_list=[];
if (isset($combo_id) and $combo_id != 0) {
// $combo=DB::table('combos')->where(['hospital_id'=>$hospital_id,'combo_id'=>$combo_id,'status'=>1])->first();
$combo = DB::select("select a.*,b.*,c.name as crowd_name from combos as a LEFT JOIN (
select combo_id as c_id,count(*) as sale_count from orders where status in(2,4) group by combo_id
) as b on a.combo_id=b.c_id left join combo_crowd as c on a.crowd_id=c.id where a.combo_id=? and a.status=1 ", [$combo_id]);
if (!$combo) return \Yz::echoError1("套餐不存在");
$combo = $combo[0];
//构建多选一数据
$Nx1_arrInfo=[];
if(isset($duo_xuan_yi) and !empty($duo_xuan_yi)){
$combo_Nx1=json_decode($combo->duo_xuan_yi,true);
foreach ($duo_xuan_yi as $r_k=>$r_v){
foreach ($combo_Nx1 as $k=> $n1v){
if($r_v['zu_name'] == $n1v['组名称']){
foreach ($n1v['包含项目'] as $k2 => $v2){
if($v2['Id'] == $r_v['item_id']){
if($v2['科室名称']=='影像科'){
$nmr_list[]=[
'item_id' => $v2['Id'],
'name' => $v2['名称'],
'price' => $v2['价格'],
];
}
$Nx1_arrInfo[] = [
'id' => $v2['Id'],
'name' => $v2['名称'],
'desc' => $v2['简介'],
'keshi_name' => $v2['科室名称'],
];
}
}
}
}
}
}
$combo_info['hospital_name'] = $hospital->name;
$combo_info['combo_name'] = $combo->name;
$combo_info['crowd_name'] = $combo->crowd_name;
$combo_info['img'] = $combo->cover;
$combo_info['sale_count'] = $combo->sale_count==null?0:$combo->sale_count;
$tags = json_decode($combo->tags, true);
$combo->tags2 = json_decode($combo->tags2, true);
foreach ($tags as $k => $tag) {
$tags[$k] = ['text' => $tag,
'text_color' => '#47ABD8',
'color' => '#EBF5FC'
];
}
$combo->tag = $tags;
$combo->tag[] = [
'text' => $combo->item_count . '个项目',
'text_color' => '#34C292',
'color' => '#E9F8F3',
];
$combo_info['tags'] = $combo->tag;
$combo_info['tags2'] = $combo->tags2;
$combo_info['price'] = $combo->price;
$combo_info['original_price'] = $combo->original_price;
$all_original_price += $combo_info['original_price'];
$combo_items = json_decode($combo->items, true);
$combo_items=array_merge($combo_items,$Nx1_arrInfo); //合并多选一
$groupedData = [];
$comboItemCount=0;
foreach ($combo_items as $item) {
$keshiName = $item['keshi_name'];
if($keshiName<>'材料费'){
$comboItemCount++;
}
if (!isset($groupedData[$keshiName])) {
$groupedData[$keshiName] = [];
}
$groupedData[$keshiName][] = $item;
}
foreach ($groupedData as $keshiName => $children) {
$combo_info['items'][] = [
'keshi_name' => $keshiName,
'children' => $children
];
}
$combo_info['items']= $this->KeShiPaiXu($combo_info['items']);
$pay_item_count += $combo->item_count;
$true_price += $combo_info['price'];
$combo_info['tags'][0]['text']=$comboItemCount. '个项目';
//如果有影像科则存储在nmr_list
$comboItem=DB::table('combo_items')->where(['combo_id' => $combo_id, 'status' => 1,'keshi_name'=>'影像科'])->get();
if(count($comboItem)>0){
foreach ($comboItem as $item){
$nmr_list[]=[
'item_id' => $item->item_id,
'name' => $item->name,
'price' => $item->price,
];
}
}
}
$items_info = false;//自选项目信息
$zixuan_item=[];
if (isset($item_ids) and !empty($item_ids)) {
$item_price = 0;
$items_original_price = 0;
$items = DB::table('items')->whereIn('item_id', $item_ids)->where(['status' => 1])->get();
$zixuan_item=$items;
$groupedData = [];
foreach ($items as $item) {
//判断套餐项目和自选项目是否冲突
if(isset($combo_items)){
foreach ($combo_items as $comboitem) {
if($comboitem['id']==$item->item_id) return \Yz::echoError1($item->name."已经存在,不可重复选择");
}
}
$item_price = bcadd($item_price, $item->price, 2);
// $all_original_price+=$item->original_price;
$all_original_price = bcadd($all_original_price, $item->original_price, 2);
// $items_original_price+=$item->original_price;
$items_original_price = bcadd($items_original_price, $item->original_price, 2);
$keshiName = $item->keshi_name;
if (!isset($groupedData[$keshiName])) {
$groupedData[$keshiName] = [];
}
$groupedData[$keshiName][] = ['desc' => $item->jianjie, 'name' => $item->name,'price'=>$item->price,'original_price'=>$item->original_price,'id'=>$item->item_id];
//如果有影像科则存储在nmr_list字段
if($item->keshi_name=='影像科'){
$nmr_list[]=[
'item_id' => $item->item_id,
'name' => $item->name,
'price' => $item->price,
];
}
}
if(isset($wj_flag) and $wj_flag==1){
$item_price=number_format($item_price*$wj_zhekou, 2, '.', '') ;
}
$items_info['price'] =$item_price;
$items_info['original_price'] = $items_original_price;
foreach ($groupedData as $keshiName => $children) {
$items_info['items'][] = [
'keshi_name' => $keshiName,
'children' => $children
];
}
$items_info['items']= $this->KeShiPaiXu($items_info['items']);
$pay_item_count += count($items);
$true_price += $items_info['price'];
}
//调用his接口查询用户积分和预存款计算可以抵扣的金额
$integral_money = 90;//积分抵扣金额
$save_money = 150;//预存款抵扣金额
$coupon_money = 50;//优惠券抵扣金额
$group_info = false;
$lose_price=0;
if (!!$group_id) {
$P = new PersonController();
$data = [
'电话号码' => null,
'证件号码' => null,
'预约Id' => $group_id
];
$group_info = $P->group_info($hospital_id, $data);
if(count($group_info)==0) return \Yz::echoError1("获取团检登记信息失败");
//如果是团检统收限额大于0并且没有自带项目则判断剩余金额
if($group_info[0]['tongshou_xiane']>0 and count($group_info[0]['items'])==0){
$lose_price=$group_info[0]['tongshou_xiane']- $true_price;
if($lose_price<0) $lose_price=0;
}
$true_price = $true_price + $group_info[0]['sixi_zong_ji_jin_e'];
$true_price = ($true_price - $group_info[0]['tongshou_xiane']) > 0 ? $true_price - $group_info[0]['tongshou_xiane'] : 0;
//如果有多选一项目
//构建多选一数据
$Nx1_arrInfo=[];
if(isset($duo_xuan_yi) and !empty($duo_xuan_yi) and (!isset($combo_id) or $combo_id == 0)){
foreach ($duo_xuan_yi as $r_k=>$r_v){
$Nx1_arrInfo[]=[
'id' => $r_v['item_id'],
'name' => $r_v['item_name'],
];
}
}
$group_info[0]['items'] =array_merge($group_info[0]['items'],$Nx1_arrInfo); //合并多选一
foreach ($zixuan_item as $item) {
//判断团检套餐项目和自选项目是否冲突
if (isset( $group_info[0]['items'])) {
foreach ( $group_info[0]['items'] as $group_info_item) {
if ($group_info_item['id'] == $item->item_id) return \Yz::echoError1($item->name . "已经存在,不可重复选择");
}
}
}
// return \Yz::Return(true,"",$group_info[0]['items']);
$all_items = DB::table('items')->where(['status' => 1])->get();
$item_new = [];
foreach ($group_info[0]['items'] as $item) {
$item['keshi_name'] = '其他';
$item['desc'] = '';
foreach ($all_items as $it) {
if ($it->item_id == $item['id']) {
$item['keshi_name'] = $it->keshi_name;
$item['desc'] = $it->jianjie;
if($it->keshi_name=='影像科'){
$nmr_list[]=[
'item_id' => $it->item_id,
'name' => $it->name,
'price' => $it->price,
];
}
break;
}
}
$item_new[] = $item;
}
$groupedData = [];
foreach ($item_new as $item) {
$keshiName = $item['keshi_name'];
if (!isset($groupedData[$keshiName])) {
$groupedData[$keshiName] = [];
}
$groupedData[$keshiName][] = ['desc' => $item['desc'], 'name' => $item['name'], 'id' => $item['id'], 'keshi_name' => $item['keshi_name']];
}
$group_info[0]['items'] = [];//清空原来的item
foreach ($groupedData as $keshiName => $children) {
$group_info[0]['items'][] = [
'keshi_name' => $keshiName,
'children' => $children
];
}
}
$temp_nmr=[];
$keywords = ['磁'];
foreach ($nmr_list as $key=>$item){
foreach ($keywords as $index => $keyword) {
if (strpos($item['name'], $keyword) !== false) {
// 如果找到关键字,且结果数组中还没有该关键字的记录,则初始化
if (!isset($temp_nmr[$index])) {
$temp_nmr[$index] = [
'item_id' => $item['item_id'],
'name' => $item['name'],
'price' => $item['price'],
];
} else {
// 如果已经存在记录,只拼接名称
$temp_nmr[$index]['name'] .= ' / ' . $item['name'];
}
}
}
}
// 将结果数组转换为最终格式
$finalResult = [];
foreach ($temp_nmr as $index => $data) {
$finalResult[] = [
'item_id' => $data['item_id'],
'name' => $data['name'],
'price' => $data['price']
];
}
$nmr_list=$finalResult;
//使用优惠券
if(isset($coupon_id) and !empty($coupon_id)){
if($true_price==0) return \Yz::echoError1("金额为0无需使用优惠券");
$true_price=$this->useYouHuiQuan($true_price,$person,$coupon_id);
}
$data = [
'group_info' => $group_info,
'combo_info' => $combo_info,
'items_info' => $items_info,
'integral_money' => number_format($integral_money, 2, '.', ''),
'save_money' =>number_format($save_money, 2, '.', ''),
'coupon_money' => number_format($coupon_money, 2, '.', ''),
'true_price' =>number_format($true_price, 2, '.', ''),//需要用户支付的金的
'original_price' =>number_format($all_original_price, 2, '.', '') ,//总原价
'pay_item_count' => $pay_item_count,//需要付费的项目数量
'lose_price'=>number_format($lose_price, 2, '.', ''),//剩余的不用就会浪费的金额
// 'nmr_list' => $nmr_list,//核磁项目列表
'nmr_list' => [],//不返回给前端了
'nmr_list2' => $nmr_list//核磁项目列表,重新定义一个字段用于前端携带返回
];
return \Yz::Return(true, "查询成功", $data);
}
public function ComboCompare()
{
$combo_ids = request('combo_ids'); //购买的套餐id
$combos = DB::table('combos as a')
->leftJoin('checkup_type as b', 'a.checkup_type_id', '=', 'b.id')
->select('a.*', 'b.name as checkup_type_name')
->whereIn('a.combo_id', $combo_ids)->where(['a.status' => 1])->get();
foreach ($combos as $key => $combo) {
$combo->items = json_decode($combo->items, true);
$item_list=[];
foreach ($combo->items as $key => $item) {
if($item['keshi_name']<>'材料费'){
$item_list[]=$item;
}
}
$item_list=$this->KeShiPaiXu($item_list);
$combo->items=$item_list;
$count = DB::table('orders')->where(['combo_id' => $combo->combo_id])->whereIn('status', [2, 4])->count();
$combo->saleCount = $count;
}
foreach ($combos as $key => $combo) {
$tags = json_decode($combo->tags, true);
$combo->tags2 = json_decode($combo->tags2, true);
foreach ($tags as $k => $tag) {
$tags[$k] = ['text' => $tag,
'text_color' => '#47ABD8',
'color' => '#EBF5FC'
];
}
$combo->tags = $tags;
$combo->tags[] = [
'text' => $combo->item_count . '个项目',
'text_color' => '#34C292',
'color' => '#E9F8F3',
];
}
return \Yz::Return(true, "查询完成", ['list' => $combos]);
}
//推荐套餐
public function ComboRecommend()
{
$item_ids = request('item_ids'); //购买的套餐id
$person_id = request('person_id'); //就诊人id
$person=DB::table('web_user_person')->where(['id' => $person_id,'is_del'=>0])->first();
if(!$person) return \Yz::echoError1("用户不存在");
//统计勾选的项目总额
$item_all_price=DB::table('items')->whereIn('item_id',$item_ids)->where(['status' => 1])->sum('price');
$allCombos = DB::table('combos as a')->leftJoin('combo_items as b','a.combo_id','=','b.combo_id')->whereIn('a.sex',[$person->sex,0])->where(['a.status'=>1])->get();
$combo_temp=[];
foreach ($allCombos as $key => $combo) {
$c_id=$combo->combo_id;
if (!isset($combo_temp[$c_id])) {
$groupedData[$c_id] = [];
}
$combo_temp[$c_id][] = $combo->item_id;
}
// 用于存储每个数组及其与目标数组的相似度
$similarities = [];
foreach ($combo_temp as $index => $array) {
$similarity = $this->jaccard_similarity($item_ids, $array);
$similarities[$index] = $similarity;
}
// 对相似度进行排序,保持索引关联
arsort($similarities);
// 获取最相似的前两个数组
$topTwoIndexes = array_keys($similarities, current($similarities), true); // 第一个最大值
next($similarities);
$topTwoIndexes[] = key($similarities); // 第二个最大值
$ids= "'" . implode("','", $topTwoIndexes) . "'";
$sex=$person->sex;
$combos = DB::select("select * from combos as a LEFT JOIN (
select combo_id as c_id,count(*) as count from orders where status in(2,4) group by combo_id
) as b on a.combo_id=b.c_id where a.status=1 and a.combo_id in (".$ids.") and a.sex in(".$sex.",0)");
foreach ($combos as $key => $combo) {
$tags = json_decode($combo->tags, true);
$combo->tags2 = json_decode($combo->tags2, true);
foreach ($tags as $k => $tag) {
$tags[$k] = ['text' => $tag,
'text_color' => '#47ABD8',
'color' => '#EBF5FC'
];
}
$combo->tags = $tags;
$combo->tags[] = [
'text' => $combo->item_count . '个项目',
'text_color' => '#34C292',
'color' => '#E9F8F3',
];
$combo->recommend = [
'xiangsidu' => (string)(number_format($similarities[$combo->combo_id],2)*100).'%',
'count' => $combo->item_count-count($item_ids),
'money' => number_format($combo->price - $item_all_price,2)
];
}
$list=[];
foreach ($combos as $key => $combo) {
if($combo->recommend['xiangsidu']<>'0%'){
$list[]=$combo;
}
}
return \Yz::Return(true, "查询完成", ['combos' => $list]);
}
function jaccard_similarity($set1, $set2) {
// 计算交集
$intersection = array_intersect($set1, $set2);
// 计算并集
$union = array_unique(array_merge($set1, $set2));
// 避免除数为0的情况
if (count($union) == 0) return 0;
// 返回Jaccard相似度
return count($intersection) / count($union);
}
//使用优惠券
public function useYouHuiQuan($true_price,$person,$coupon_id){
$env=config('app.globals.Env');
//如果使用了代金券
if(isset($coupon_id) and !empty($coupon_id)){
if($true_price==0) return \Yz::echoError1("无需使用代金券");
$quanInfo=false;
if($env=='pro') { //如果是正式环境
$AspNet=new AspNetZhuanController();
$data=[
'ghzid'=>$person->ghzid,
'action'=>1,
];
$YouHuiQuanList=$AspNet::YouHuiQuan($data);
foreach ($YouHuiQuanList as $key=>$quan){
if($quan['DZJID']==$coupon_id){
$quanInfo=$quan;
}
}
if(!!$quanInfo and $quanInfo['是否在有效内']===true and $quanInfo['TimeNuZTTextm']=="有效" and $quanInfo['ZT']==1){
}else{
return \Yz::echoError1("此代金券不可用");
}
$quanType=false;
$YouHuiQuanType=$AspNet::YouHuiQuan(['action'=>2]);
foreach ($YouHuiQuanType as $key=>$type){
if($quanInfo['DZJLBID']==$type['DZJLBID']){
$quanType=$type;
}
// if($type['TJXCXHX']==1 and ($type['MKJE']===0 || $type['MKJE']>=$true_price)){
// $YouHuiQuanType_ids[]=$type['DZJLBID'];
// }
}
if($quanType===false or $quanInfo===false) return \Yz::echoError1("此代金券不可用");
if($quanType['TJXCXHX']!=1 ) return \Yz::echoError1("此代金券不可用");
if($quanType['MKJE']==0 or $quanType['MKJE']>=$true_price){
//抵扣代金券金额
if($quanType['YHLX']==1){//抵扣券
$true_price=($true_price-$quanInfo['JE'])>0 ? $true_price-$quanInfo['JE']:0;
}
if($quanType['YHLX']==2){//抵扣券
$true_price=number_format($true_price*$quanType['DZBL'],2, '.', '');
}
}
}
return $true_price;
}
}
public function KeShiPaiXu($data)
{
// 给定的科室顺序
$sortedOrder = config('app.globals.KeShiPaiXu');
// 创建一个科室到其在期望顺序中位置的映射
$sortedOrderMap = array_flip($sortedOrder);
// 使用 usort 函数进行排序
usort($data, function($a, $b) use ($sortedOrderMap) {
// 获取两个科室在期望顺序中的位置
$posA = isset($sortedOrderMap[$a['keshi_name']]) ? $sortedOrderMap[$a['keshi_name']] : PHP_INT_MAX;
$posB = isset($sortedOrderMap[$b['keshi_name']]) ? $sortedOrderMap[$b['keshi_name']] : PHP_INT_MAX;
// 比较两个位置,确定排序
return $posA - $posB;
});
return $data;
}
}

@ -0,0 +1,178 @@
<?php
namespace App\Http\Controllers\API\H5;
use App\Http\Controllers\API\AspNetZhuanController;
use App\Http\Controllers\Controller;
use DateInterval;
use DatePeriod;
use DateTime;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class DoctorController extends Controller
{
//获取体检医生列表
public function GetList()
{
$date = request('date');
$hospital = request('hospital');
$month = request('month');
$doctor_id = request('doctor_id');
$person_id = request('person_id');
$checkup_type = request('checkup_type');
$zhou_firstday = request('zhou_firstday');
if(!isset($person_id)) return \Yz::echoError1("用户id缺失");
$personInfo=DB::table('web_user_person')->where('id',$person_id)->first();
$hospital_map = [
'h1' => '6',
'h4' => '2',
];
$datesArray = [];
if (isset($date)) {
$datesArray[] = $date;
}elseif(isset($month) and $month == 'all') {
// 循环30次每次获取一天后的日期
for ($i = 0; $i < 31; $i++) {
// 使用strtotime函数计算$i天后的日期然后用date函数格式化日期
$datesArray[] = date('Y-m-d', strtotime("+$i days"));
}
}
if (isset($month) and (strlen($month) == 7 or strlen($month) == 6)) {
$firstDay = strtotime($month . '-01');
// 获取该月的最后一天
$lastDay = strtotime('+1 month', $firstDay) - 86400; // 减去一天的秒数86400秒得到最后一天
// 从第一天到最后一天,逐天添加到数组中
$currentDay = $firstDay;
while ($currentDay <= $lastDay) {
$datesArray[] = date('Y-m-d', $currentDay);
$currentDay = strtotime('+1 day', $currentDay);
}
}
if (empty($datesArray)) return \Yz::Return(false,"参数错误");
$dnet = new AspNetZhuanController();
$res = $dnet->GetDoctorDateList([
"yyid" => $hospital_map["h$hospital"],
"data" => $datesArray,
"action" => "1"
]);
//return \Yz::Return(true,"",['data'=>$res]);
$list = [];
$keshi=[
'A0030090'=>'内科',
'A0030091'=>'妇科',
'A0030102'=>'外科'
];
$keshi_sex_list=[
'A0030116'=>'2',
'A0030106'=>'1'
];
if(isset($checkup_type) and $checkup_type == '4'){
$keshi_sex_list=[
'A0030087'=>'1',
'A0030089'=>'2'
];
}
if ($res['code'] == '200' && count($res['yisheng']) != 0) {
foreach ($res['yisheng'] as $key => $value) {
$keshiname='';
$keshi_sex='';
if(isset($keshi[$value['KSID']])){
$keshiname=$keshi[$value['KSID']];
}
if(isset($keshi_sex_list[$value['KSID']])){
$keshi_sex=$keshi_sex_list[$value['KSID']];
}
if($keshi_sex==$personInfo->sex){
$is_paiban=false;
if(isset($res['paiban'])){
foreach ($res['paiban'] as $key => $date_value) {
foreach ($date_value as $key2 => $value2) {
if($value2['YSID']== $value['U_ID'] and $value2['KSID']==$value['KSID']){
$is_paiban=true;
break;
}
}
if($is_paiban) break;
}
}
if($is_paiban){
$list[] = [
'head_img' => 'data:image/jpeg;base64,' . $value['U_IMG'],
'name' => $value['U_NAME'],
'id' => $value['U_ID'],
'level' => $value['ZC_NAME'],
'hospital' => '',
'time' => $value['U_GDPB'],
'desc' => $value['U_JIANJIE'],
'keshiname'=>$keshiname,
'keshi_id'=>$value['KSID'],
'keshi_sex'=>$keshi_sex,
];
}
}
}
}
$paiban=[];
$dates=[];
if(isset($month) and (strlen($month) == 7 or strlen($month) == 6) and isset($doctor_id)){
$k=0;
foreach ($res['paiban'] as $key => $date_value) {
foreach ($date_value as $key2 => $value2) {
if($value2['YSID']==$doctor_id and $keshi_sex_list[$value2['KSID']]==$personInfo->sex){
$paiban[]=$value2;
}
}
}
$firstDay = date("Y-m-d", strtotime($month . "-01"));
// 获取当月的最后一天
$lastDay = date("Y-m-t", strtotime($month));
for ($i = $firstDay; $i <= $lastDay; $i = date("Y-m-d", strtotime($i . " +1 day"))) {
foreach ($paiban as $key => $value) {
if(date('Y-m-d', strtotime($value['PBRQ']))==$i){
$dates[]=[
'date'=>$i,
'paiban'=>$value,
];
}
}
$k++;
}
}
//7日内的日期
$startDate = new DateTime('today'); // 设置开始时间为今天
if(isset($zhou_firstday)){
$startDate = new DateTime($zhou_firstday);
}
$endDate = clone $startDate;
$endDate->modify('+6 days'); // 结束时间为今天之后的第6天
$period = new DatePeriod($startDate, new DateInterval('P1D'), $endDate);
$week7=[];
foreach ($period as $date) {
$f_date=$date->format('Y-m-d');
$xingqi=\App\Lib\Tools::GetWeekName($f_date);
$week7[]=[
'date'=>$f_date,
'xingqi'=>$xingqi
];
}
$f_date=$endDate->format('Y-m-d');
$xingqi=\App\Lib\Tools::GetWeekName($f_date);
$week7[] = [
'date'=>$f_date,
'xingqi'=>$xingqi
];
return \Yz::Return(true, "查询完成", ['list' => $list, 'paiban' => $dates, 'week7' => $week7]);
}
}

@ -0,0 +1,490 @@
<?php
namespace App\Http\Controllers\API\H5;
use App\Http\Controllers\API\AspNetZhuanController;
use App\Http\Controllers\Controller;
use App\Services\ComboItemGroupService;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use App\Services\OrderService;
class FenzhenController extends Controller
{
public static $log = null;
public function abandon()
{
// 这里放 弃检逻辑
$id = request('id');
$xmid = request('xmid');
$orderInfo = DB::table('orders')->where('id', $id)->first();
if (!$orderInfo) return \Yz::echoError1("订单不存在");
$service = new ComboItemGroupService();
$q = $service->QiJian($orderInfo->tj_number, $orderInfo->name, [$xmid]);
if ($q['status'] === true) {
self::fenzhenAbandon($orderInfo, $xmid);
return \Yz::Return(true, "弃检成功", []);
} else {
return \Yz::echoError1($q['msg']);
}
}
public function fenzhenAbandon($orderInfo, $xmid)
{
$data = [
'name' => $orderInfo->name,
'id_number' => $orderInfo->id_number,
'uuid' => $orderInfo->tj_number,
'type' => '',
'check_type' => '1',
'sex' => $orderInfo->sex,
'birthday' => $orderInfo->birthday,
'phone' => $orderInfo->phone,
'registration_number' => $orderInfo->plan_number,
'items' => [],
'drops' => [(string)$xmid],
'regenerate' => '1',
'line_up' => '1',
'mute' => '2',
'show' => '1',
];
self::fz('abandon', $data);
}
public function check()
{
// 这里放 检查是否有 体检引导的数据
$id_number = request('id_number');
$type = 1;
$list = DB::table('orders')->where(['id_number' => $id_number])->where('appointment_date', '>=', date('Y-m-d'))
->whereIn('status', [2, 4])->orderBy('id', 'desc')->get();
if (count($list) == 0) {
$type = 2;
$list = DB::table('orders')->where(['id_number' => $id_number])->whereIn('status', [2, 4])->where('tj_number', '!=', null)->get();
if (count($list) == 0) {
$type = 3;
$list = DB::table('orders')->where(['id_number' => $id_number])->whereIn('status', [2, 4])->orderBy('id', 'desc')->get();
}
} else {
$l = [$list[0]];
$list = $l;
}
return \Yz::Return(true, "弃检成功", [
'list' => $list,
'type' => $type
]);
}
public function list()
{
$id = request('id');
$info = DB::table('orders')->where(['id' => $id])->whereIn('status', [2, 4])->first();
if (!$info) return \Yz::echoError1("查询就诊人订单失败");
$end_time = date('H:i', strtotime($info->appointment_date . ' ' . $info->appointment_time) + (60 * 60 * 0.54));
$clinics = [];
$order = new OrderService();
$order_data = $order->DepartmentItemCount($info->id);
$clinics = $order_data['department_list'];
$report_day = $order_data['wait_day'];
$is_checked_sign_in = $order_data['is_checked_sign_in'];
$error_day = $report_day;
if ($report_day == -1) {
$report_day = false;
}
// return \Yz::Return(true, "查询成功", [
// 'a'=>$order_data
// ]);
$res = self::fz('time', [
'exam_id' => $info->tj_number ?? '??????????',
'start_time' => date('H:i', strtotime($info->appointment_date . ' ' . $info->appointment_time)),
'clinics' => $clinics
]);
$KaHao='';//卡号
$person_ghzid = '';
$dnet = new AspNetZhuanController();
$res2 = $dnet->GetPersonInfo([
"zjh" => $info->id_number,
"action" => "2",
"ghzid"=>""
]);
$KaHao=isset($res2['data'][0]['KH'])?$res2['data'][0]['KH']:'';
$person_info = DB::table('web_user_person')->where('id', $info->web_user_id)->first();
if (!!$person_info) {
$person_ghzid = $person_info->ghzid;
}
if (!!$res) {
$time_line = $res['data']['time_line'];
$clinic_map = [];
foreach ($time_line as $key => $item) {
if (isset($item['his_number'])) {
$clinic_map[] = $item['his_number'];
}
}
$last_time = strtotime('2024-10-10 ' . $time_line[count($time_line) - 1]['time'] . ':00');
if (!$res['data']['queue']) {
$push_end = false;
foreach ($clinics as $item) {
if (!in_array($item['keshi_id'], $clinic_map)) {
$push_end = true;
$item_count = $item['count'];
$in_time = date('H:i', $last_time);
$time_line = array_merge(array_splice($time_line, 0, count($time_line) - 1), [
[
"desc" => "预计 $in_time 进入队列",
"more" => 0,
"name" => $item['name'],
"status" => 1,
'count' => -1,
"time" => "$in_time",
"tip" => "剩余{$item_count}项正在排队中,"
]
], [$time_line[count($time_line) - 1]]);
$last_time = $last_time + (60 * 5);
}
}
if ($push_end) {
$in_time = date('H:i', $last_time);
$time_line = array_merge(array_splice($time_line, 0, count($time_line) - 1), [
[
"desc" => "结束时间 $in_time",
"more" => 0,
"name" => "体检结束",
"status" => -1,
'count' => -1,
"time" => "$in_time",
"tip" => ""
]
]);
}
}
$end_status = 0;
$tip_check_show = false;
foreach ($time_line as $time_line_item) {
if ($time_line_item['status'] == 4) {
$end_status += 1;
}
}
if (count($time_line) <= $end_status + 1) {
$tip_check_show = true;
$time_line[count($time_line) - 1]['status'] = 4;
}
// -1 报告未出 不能预约 报告解读 不显示
// 0 时间未到 不能预约 报告解读 不显示
// 1 时间已到 可以预约 报告解读
// 2 已经预约 报告解读
$check_report_status = -1;
$now_time = time();
// $now_time = strtotime('2024-11-07 00:00:00');
if (!!$res['data']['report']) {
if ($report_day !== false) {
$report_status = false;
$report_time = strtotime($res['data']['report'] . ' 00:00:00') + (60 * 60 * 24 * $report_day);
$report_time_show = date('m月d日', $report_time);
// 这里补充 获取 出具报告 时间的逻辑
if ($report_time < $now_time) {
$report_status = true;
}
if (!$report_status) {
$time_line[] = [
'time' => '',
'name' => '出具报告',
'status' => -1,
'count' => -1,
'desc' => "预计 $report_time_show 出具体检报告",
'tip' => '',
'more' => 0
];
} else {
$time_line[] = [
'time' => '',
'name' => '出具报告',
'status' => -1,
'count' => -1,
'desc' => "已出具体检报告 $report_time_show",
'tip' => '',
'more' => 0
];
}
$check_report_time = $report_time + (60 * 60 * 24);
$check_report_status = 0;
// $check_report_status = '2024年10月11日';
// 这里补充 获取 报告解读 时间的逻辑
if ($check_report_time < $now_time) {
if (!!$info->person_id) {
$user_info = DB::table('web_user_person')->where(['id' => $info->person_id])->first();
if (!!$user_info) {
$hospital_map = [
'h1' => '6',
'h4' => '2'
];
$dnet = new AspNetZhuanController();
$hid = $info->hospital_id;
$report_res = $dnet->GetReportAnalysis([
"yyrq" => date('Y-m-d', $check_report_time),
"ghzid" => $user_info->ghzid,
"yyid" => $hospital_map["h$hid"],
"action" => "1"
]);
switch ($report_res['code']) {
case '200':
$check_report_status = 2;
$show_date = date('m-d', strtotime($report_res['yyrq']));
$time_line[] = [
'time' => '',
'name' => '报告解读',
'status' => -1,
'count' => -1,
'desc' => "已预约 $show_date 报告解读",
'tip' => '',
'more' => 0
];
break;
case '199':
case '201':
$check_report_status = 1;
$time_line[] = [
'time' => '',
'name' => '报告解读',
'status' => -1,
'count' => -1,
'desc' => "可以预约报告解读",
'tip' => '',
'more' => 0
];
break;
case '202':
$check_report_status = 0;
$time_line[] = [
'time' => '',
'name' => '报告解读',
'status' => 1,
'count' => -1,
'desc' => "已完成报告解读",
'tip' => '',
'more' => 0
];
break;
}
}
}
} else {
$check_report_time_show = date('m月d日', $check_report_time);
$time_line[] = [
'time' => '',
'name' => '报告解读',
'status' => -1,
'count' => -1,
'desc' => "预计 $check_report_time_show 可以预约报告解读",
'tip' => '',
'more' => 0
];
}
}
}
if (!$tip_check_show) {
$res['data']['end_time'] = date('H:i', $last_time);
}
$check_tip = false;
// \Yz::debug(['$is_checked_sign_in'=>$is_checked_sign_in,'$error_day'=>$error_day]);
if (!!$is_checked_sign_in) {
if ($error_day == -1) {
if (!!$tip_check_show) {
$et = $info->appointment_date . ' ' . $res['data']['end_time'] . ':00';
$check_tip = (time() - strtotime($et)) > (60 * 20);
}
}
}
return \Yz::Return(true, "获取成功", [
'info' => [
'name' => $info->name,
'sex' => $info->sex,
'combo_name' => $info->title,
'check_date' => $info->appointment_date,
'plan_number' => $info->plan_number,
'start_time' => $res['data']['start_time'] . ':00',
'end_time' => $res['data']['end_time'],
'yuji_end_time' => $res['data']['yuji_end_time'],
'yuji_use_time' => $res['data']['yuji_use_time'],
'use_time' => $res['data']['use_time'],
'qrcode' => $person_ghzid,
'tj_number' => $info->tj_number,
'ghzid' => $person_ghzid,
'kahao'=>$KaHao,
'code' => $info->appointment_number,
],
'list' => $time_line,
'report' => $check_report_status,
'check_tip' => $check_tip,
]);
} else {
return \Yz::Return(true, "获取成功", [
'info' => [
'name' => $info->name,
'sex' => $info->sex,
'combo_name' => $info->title,
'check_date' => $info->appointment_date,
'plan_number' => $info->plan_number,
'start_time' => $info->appointment_time,
'end_time' => $end_time,
'yuji_end_time' => $end_time,
'yuji_use_time' => '',
'use_time' => '',
'qrcode' => $person_ghzid,
'ghzid' => $person_ghzid,
'kahao'=>$KaHao,
'tj_number' => $info->tj_number,
'code' => $info->appointment_number,
],
'list' => [],
'report' => -1,
'check_tip' => false,
]);
}
}
public function info()
{
$id = request('id');
$clinic = request('clinic');
$info = DB::table('orders')->where(['id' => $id])->whereIn('status', [2, 4])->first();
if (!$info) return \Yz::echoError1("查询就诊人订单失败");
$res = self::fz('info', [
'exam_id' => $info->tj_number ?? '??????????',
'clinic' => $clinic,
]);
$person_ghzid = '';
$person_info = DB::table('web_user_person')->where('id', $info->person_id)->first();
if (!!$person_info) {
$person_ghzid = $person_info->ghzid;
}
if (!!$res) {
if ($res['code'] == 200) {
$item_list = $res['data']['list'];
foreach ($item_list as $item_index => $item_info) {
$db_item = DB::table('items')
->where('item_id', $item_info['id'])
->first();
if (!!$db_item) {
$item_list[$item_index]['desc'] = self::item_desc($db_item);
} else {
$item_list[$item_index]['desc'] = '';
}
}
return \Yz::Return(true, "获取成功", [
'info' => [
'name' => $info->name,
'sex' => $info->sex,
'combo_name' => $info->title,
'check_date' => $info->appointment_date,
'start_time' => $info->appointment_time,
'end_time' => '10:25',
'qrcode' => $person_ghzid,
'ghzid' => $person_ghzid,
'tj_number' => $info->tj_number,
'code' => $info->appointment_number,
],
'list' => $item_list,
]);
} else {
return \Yz::Return(false, $res['message']);
}
} else {
return \Yz::Return(false, "获取失败");
}
}
public function item_desc($item)
{
// $canqian = $item->can_qian_hou == '餐前' ? '餐前' : '';
$beizhu = !!$item->beizhu ? $item->beizhu : '';
$tishi = !!$item->tishi ? $item->tishi : '';
$ret = [];
// if (!!$canqian) {
// $ret[] = $canqian;
// }
if (!!$beizhu) {
$ret[] = $beizhu;
}
if (!!$tishi) {
$ret[] = $tishi;
}
return count($ret) == 0 ? '' : '(' . implode(',', $ret) . ')';
}
public function post($url, $data)
{
$data_string = json_encode($data, JSON_UNESCAPED_UNICODE);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Content-Type: application/json; charset=utf-8',
'Content-Length: ' . strlen($data_string),
'Authorization: Bearer BD30333C-CBD4-4BA3-A27C-76727FF4D8B1'
]);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);
$r = curl_exec($curl);
curl_close($curl);
return $r;
}
public function fz($type, $content)
{
$date = date('Y-m-d');
self::CheckTableName(date('Y-m-d'));
self::$log->date = $date;
self::$log->type = $type;
self::$log->content = json_encode($content, JSON_UNESCAPED_UNICODE);
self::$log->callback = '{}';
self::$log->save();
$url_map = [
'time' => '/api/Open/TiJian/get',
'info' => '/api/Open/TiJian/info',
'search' => '/api/Open/TiJian/search',
'change' => '/api/Open/TiJian/change',
'export' => '/api/Open/TiJian/export',
'abandon' => '/api/Open/Queue/registration?client=open',
];
$url = env('FENZHEN_URL');
$res = self::post("$url{$url_map[$type]}", $content);
// /api/Open/TiJian/get
self::$log->callback = $res;
self::$log->save();
if (json_decode($res)) {
return json_decode($res, true);
} else {
return false;
}
}
public static function CheckTableName($date)
{
$table_name = 'zz_fenzhen_log_' . date('ym', strtotime($date));
$table_count = DB::select('select count(1) as c from information_schema.TABLES where table_schema = ? and table_name = ?', [env('DB_DATABASE'), $table_name])[0];
if ($table_count->c === 0) {
Schema::create($table_name, function (Blueprint $table) {
$table->id();
$table->date('date')->index();
$table->string('type', 20)->index();
$table->longText('content');
$table->longText('callback');
$table->timestamps();
});
}
self::$log = new \App\Models\FenzhenLog;
self::$log->setTable($table_name);
return $table_name;
}
}

@ -0,0 +1,157 @@
<?php
namespace App\Http\Controllers\API\H5;
use App\Http\Controllers\Controller;
use App\Services\ConfigService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class HomeController extends Controller
{
// 获取配置更新时间
public function config_version()
{
$version = DB::table('configs')->where(['label' => 'H5配置版本'])->first();
$version = $version->value;
return \Yz::Return(true, '获取成功', [
'version' => $version
]);
}
// 获取配置更新时间
public function config()
{
$hospitals = DB::table('hospitals')
->select("id", "name", "latitude", "longitude", "logo","address")
->where(['status' => 1, 'is_del' => 0])->get();
if (count($hospitals) < 1) return \Yz::echoError1('');
$db_config = DB::table('configs')->whereIn('label', ['首页欢迎词', '首页banner'])->get();
$config = [
'hospital' => $hospitals,
// [[
// 'id' => 1,
// 'name' => '秀英院区',
// 'latitude' => '39.867671',
// 'longitude' => '119.514223',
// ]]
'tip' => $this->getValueByLabel($db_config, '首页欢迎词'),
'logo' => $hospitals[0]->logo,
'banner' => [
'image' => $this->getValueByLabel($db_config, '首页banner'),
'jump' => 'https://www.hnxd.org/list-jkglzx.html',
],
'order' => [[
'message' => '',
'name' => '个人体检预约',
'jump' => '/pages/buy/choose/choose?url=api://CheckUpTypeGetList',
'icon' => '/assets/h5/gejianyuyue.png'
], [
'message' => '',
'name' => '单位体检预约',
'jump' => '/pages/main/tj/choose',
'icon' => '/assets/h5/tuanjianyuyue.png'
]],
'button' => [[[
'message' => '',
'name' => '健康问卷',
'jump' => '/pages/main/question/choose/choose',
'icon' => '/assets/h5/a_jiankangwenjuan.png'
],
// [
// 'message' => '暂未开放',
// 'name' => '预检咨询',
// 'jump' => '/pages/main/cjwt/cjwt',
// 'icon' => '/assets/h5/changjianwenti.png'
// ],
[
'message' => '',
'name' => '体检注意事项',
'jump' => '/pages/posts/posts/posts?type=2',
'icon' => '/assets/h5/a_tijianzhuyishixiang.png'
], [
'message' => '',
'name' => '体检引导',
'jump' => '/pages/user/pick/pick',
'icon' => '/assets/h5/a_tijianyindao.png'
]], [[
'message' => '',
'name' => '报告解读预约',
'jump' => 'XCX/pages/other/entry/index?path=/pages/outpatient/doctor-appointment/index&scene=1035&hospitalAreaId=6&departmentCode=A0030077&subDepartmentCode=4773794195699464904',
'icon' => '/assets/h5/a_jiedubaogao.png'
], [
'message' => '',
'name' => '健康指导',
'jump' => '/pages/posts/posts/posts?type=1',
'icon' => '/assets/h5/a_jiankangzhidao.png'
], [
'message' => '',
'name' => '满意度调查',
'jump' => '/pages/main/questionnaire/index',
// 'jump' => 'https://www.wjx.cn/vm/Q9A0NRI.aspx',
'icon' => '/assets/h5/a_manyidudiaocha.png'
]], [[
'message' => '',
'name' => '报告查询',
'jump' => '/pages/main/bgcx/bgcx',
'icon' => '/assets/h5/a_baogaochaxun.png'
],
[
'message' => '',
'name' => '健康宣教',
'jump' => '/pages/posts/posts/posts?type=4',
'icon' => '/assets/h5/xuanjiao.png'
],
[
'message' => '',
'name' => '我的订单',
'jump' => '/pages/main/order/order',
'icon' => '/assets/h5/a_wodedingdan.png'
]
]
],
'color' => true,
];
return \Yz::Return(true, '获取成功', [
'config' => $config
]);
}
//点击个检获取页面按钮
public function GetGeJianButtonList()
{
$list = [
[
'message' => '',
'name' => '检前健康评估',
'url' => '/pages/main/question/question/question?id=4',
'logo' => '/assets/h5/zhuyishixiang.png'
],
[
'message' => '',
'name' => '套餐预约',
'url' => '/pages/main/combo/combo',
'logo' => '/assets/h5/zhuyishixiang.png'
],
[
'message' => '',
'name' => '项目自选',
'url' => '/pages/main/tj/tjzx',
'logo' => '/assets/h5/zhuyishixiang.png'
]
];
return \Yz::Return(true, "查询完成", ['list' => $list]);
}
function getValueByLabel($items, $label)
{
foreach ($items as $item) {
if ($item->label === $label) {
return $item->value;
}
}
return null; // 如果没有找到匹配的 label则返回 null
}
}

@ -0,0 +1,24 @@
<?php
namespace App\Http\Controllers\API\H5;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class HospitalExtraController extends Controller
{
//获取注意事项
public function GetReadme()
{
$type= request('type');
$readme_config="1、检前受检者保证充足睡眠时间保持良好身心状态。体检当日须空腹体检前一日避免油腻、辛辣刺激性食物勿饮酒彩超男士适量憋尿女士须憋足量尿。<br/>\n2、体检时着宽松衣物不要佩戴金属物品以防丢失或影响检查结果。<br/>\n3、做妇科检查的女士请避开生理期48小时内避免性生活。\n1未婚有性生活史选择检查妇科的需签署妇科知情同意书方可进行检查。<br/>\n4、孕期、哺乳期及半年内有备孕计划的男士、女士不建议做胸片、CT、钼靶、碳13、碳14检查。<br/>\n5、体检时服用特殊药品或身体有其它不适症状请及时向检查医师说明<br/>\n6、涉及幽门螺杆菌检查项目的碳13或14近期吃过胃药及消炎药的请提醒护士以免影响数值<br/>\n7、做过心脏支架、搭桥手术、四肢有钢钉钢板、腿部有严重静脉曲张者请您不要选做动脉硬化检测。<br/>\n8、体检结束后将指引单交回前台如未体检完成请勿将指引单带走。<br/>\n备注当日因各种原因未体检完成的请尽快补检完成。";
//type=2 婚检注意事项
if(isset($type) and $type==2){
$info=DB::table("articles")->where("id",75)->first();
$readme_config=$info->content;
}
return \Yz::Return(true,"查询完成",['content'=>$readme_config]);
}
}

@ -0,0 +1,120 @@
<?php
namespace App\Http\Controllers\API\H5;
use App\Http\Controllers\API\AspNetZhuanController;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class IntegralSaveMoneyCouponController extends Controller
{
//获取用户基本信息和积分、优惠券、预存款信息
public function GetInfo()
{
$openid =request('openid');
$person_id =request('person_id');
$combo_id =request('combo_id');
$user=DB::table('web_users')->where(['openid'=>$openid,'status'=>1,'is_del'=>0])->first();
if(!$user) return \Yz::echoError1('openid对应用户不存在');
$person=DB::table('web_user_person')->where(['user_id'=>$user->id,'is_del'=>0,'id'=>$person_id])->first();
if(!$person) return \Yz::echoError1('就诊人信息查询失败');
$quan_ids=false;
if(isset($combo_id)){
$quan_ids=DB::table('coupons_combos')->where(['combo_id'=>$combo_id])->pluck('coupon_hisid')->toArray();
}
$jifen=0;
$yucunkuan=0;
$YouHuiQuanType_ids=[];
$coupon_list=[];
$env=config('app.globals.Env');
if($env=='pro') { //如果是正式环境
$AspNet=new AspNetZhuanController();
$jifen= $AspNet::GetJiFen_YuCunKuan(1,$person->ghzid);
$yucunkuan= $AspNet::GetJiFen_YuCunKuan(2,$person->ghzid);
$YouHuiQuanType=$AspNet::YouHuiQuan(['action'=>2]);
foreach ($YouHuiQuanType as $key=>$type){
if($type['TJXCXHX']==1){
$YouHuiQuanType_ids[]=$type['DZJLBID'];
}
}
if(count($YouHuiQuanType_ids)>0 and isset($combo_id)){ //如果没有选择套餐,则不显示优惠券
$data=[
'ghzid'=>$person->ghzid,
'action'=>1,
];
$YouHuiQuanList=$AspNet::YouHuiQuan($data);
foreach ($YouHuiQuanList as $key=>$quan){
if(in_array($quan['DZJLBID'],$YouHuiQuanType_ids) and $quan['是否在有效内']===true and $quan['TimeNuZTTextm']=="有效" and $quan['ZT']==1){
if(isset($combo_id) and !in_array($quan['DZJLBID'],$quan_ids)){continue;} //如果设置了套餐id,则比对券id是否绑定套餐只有绑定的才能显示
$coupon_list[]=[
'id'=>$quan['DZJID'],
"title"=>$quan['DZJLBMC'],
"date_range"=>[substr($quan['YSQKSSJ'],0,10),substr($quan['YSQJSSJ'],0,10)],
'price'=>$quan['JE'],
"desc"=>$quan['DZJLBMC']
];
}
}
}
}
if($env=='dev') {//如果是开发环境
$jifen=50;
$yucunkuan=20;
$coupon_list=[
[
'id'=>1,
"title"=>"新人专属",
"date_range"=>['2024-05-01','2024-12-31'],
'price'=>'12',
"desc"=>"满299可用"
],
[
'id'=>2,
"title"=>"新人专属2",
"date_range"=>['2024-08-01','2024-11-10'],
'price'=>'60',
"desc"=>"满500可用"
]
];
}
return \Yz::Return(true,"查询完成",[
'person'=>$person,
'integral'=>$jifen,
'save_money'=>$yucunkuan,
'coupon_list'=>$coupon_list,
]);
}
//获取本单可用积分
public function UsableIntegralSaveMoney(){
$ysje =request('ysje');
$ssje =request('ssje');
$type =request('type'); //1积分2预存款预存款暂时不用此接口查
$openid =request('openid');
$person_id =request('person_id');
if(!isset($type)) return \Yz::echoError1("type不能为空");
$user=DB::table('web_users')->where(['openid'=>$openid,'status'=>1,'is_del'=>0])->first();
if(!$user) return \Yz::echoError1('openid对应用户不存在');
$person=DB::table('web_user_person')->where(['user_id'=>$user->id,'is_del'=>0,'id'=>$person_id])->first();
if(!$person) return \Yz::echoError1('就诊人信息查询失败');
$count=0;
$env=config('app.globals.Env');
if($env=='pro') { //如果是正式环境
$AspNet=new AspNetZhuanController();
$count= $AspNet::GetEnableCount($person->ghzid,$ysje,$ssje);
}
if($env=='dev') {//如果是开发环境
$count=30;
}
if($type==1){
return \Yz::Return(true,"查询完成",['keyong_jifen'=>$count]);
}
return \Yz::echoError1("查询失败");
}
}

@ -0,0 +1,88 @@
<?php
namespace App\Http\Controllers\API\H5;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class ItemController extends Controller
{
//获取全部自选项目
public function GetItems()
{
$openid= request('openid');
$person=DB::table('web_users as a') ->leftJoin('web_user_person as b' ,'a.id','=','b.user_id')
->where(['openid'=>$openid,'b.is_del'=>0,'b.is_default'=>1])
->first();
if(!$person) return \Yz::echoError1("就诊人信息不存在");
//查询所有可以自选的项目
$items=DB::table('items')->where(['is_choose'=>1,'status'=>1])->get();
$search= request('search');
$list = [];
$group_arr = [];
$group_list = [];
$items= $this->KeShiPaiXu($items);
foreach ($items as $item) {
if($item->sex <> $person->sex and $item->sex<>0){
continue;
}
$push_type = false;
if ($search == '') {
$push_type = true;
} else {
$check_name = $item->name;
if (strpos($check_name, $search) !== false) {
$push_type = true;
}
$check_py = $item->pinyin;
if (strpos($check_py, mb_strtoupper($search)) !== false) {
$push_type = true;
}
$check_group = $item->keshi_name;
if (strpos($check_group, $search) !== false) {
$push_type = true;
}
}
if ($push_type) {
if (!in_array($item->keshi_id, $group_arr)) {
$group_list["科室{$item->keshi_id}"] = [
'id' => $item->keshi_id,
'title' => $item->keshi_name,
'head_img'=>'/storage/20240822/banner1.png',
'children' => [],
];
$group_arr[] = $item->keshi_id;
}
$group_list["科室{$item->keshi_id}"]['children'][] = [
'id' => $item->item_id,
'title' => $item->name,
'price' =>$item->price,
'original_price'=>$item->original_price,
'pinyin' => $item->pinyin,
'desc'=>$item->beizhu
];
}
}
return \Yz::Return(true,"查询成功",['list'=>$group_list]);
}
public function KeShiPaiXu($data){
$sortOrder =config('app.globals.KeShiPaiXu');
// 创建一个映射,用于快速查找每个科室名称在排序数组中的位置
$sortMap = array_flip($sortOrder);
// 使用 sortBy 方法进行排序
$sortedData = $data->sortBy(function ($data) use ($sortMap) {
// 如果科室名称存在于映射中,则返回其位置;否则返回一个很大的数字,使其排在最后
return isset($sortMap[$data->keshi_name]) ? $sortMap[$data->keshi_name] : PHP_INT_MAX;
});
return $sortedData;
}
}

@ -0,0 +1,25 @@
<?php
namespace App\Http\Controllers\API\H5;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class LoginController extends Controller
{
public function Login()
{
$openid =request('openid');
if(!isset($openid)) return \Yz::echoError1("openid不能为空");
$user=DB::table('web_users')->where(['openid'=>$openid])->first();
if(!$user){
$user=DB::table('web_users')->insert(['openid'=>$openid]);
}
if($user){
return \Yz::Return(true,"登录成功",['openid'=>$openid]);
}else{
return \Yz::echoError1("登录失败");
}
}
}

@ -0,0 +1,167 @@
<?php
namespace App\Http\Controllers\API\H5;
use App\Http\Controllers\API\AspNetZhuanController;
use App\Http\Controllers\Controller;
use DateTime;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class NMRController extends Controller
{
//获取核磁号 本月每日剩余号源数量
public function GetMonthPlanCount()
{
$hospital_id =request('hospital_id');
$month=request('month');
// 获取给定月份的第一天
$firstDayOfMonth = date('Y-m-01', strtotime($month));
// 获取给定月份的最后一天
$lastDayOfMonth = date('Y-m-t', strtotime($month));
$today = date('Y-m-d');
$days = [];
for ($date = $firstDayOfMonth; $date <= $lastDayOfMonth; $date = date('Y-m-d', strtotime($date . ' +1 day'))) {
// 如果当前日期大于或等于今天的日期,则添加到数组中
if ($date >= $today) {
$days[] = $date;
}
}
$aspnet=new AspNetZhuanController();
$list=[];
$nmr=$aspnet::ErXian(['yyid'=>6,'data'=>$days ,'action'=>"1"],uniqid());
//获取每日数量
foreach($nmr as $k=>$v){
$t_v=[];
foreach ($v as $k1 => $v1) {
if($v1['keyong']==0){
$t_v[]=$v1;
}
}
$list[]=[
'date'=>$k,
'count'=>count($t_v)
];
}
//获取整月日期
// 获取当月的第一天
$firstDay = date("Y-m-d", strtotime($month . "-01"));
// 获取当月的最后一天
$lastDay = date("Y-m-t", strtotime($month));
$dates = array();
$k=0;
for ($i = $firstDay; $i <= $lastDay; $i = date("Y-m-d", strtotime($i . " +1 day"))) {
$xingqi=\App\Lib\Tools::GetWeekName($i);
$dates[]=[
'date'=>$i,
'xingqi'=>$xingqi,
'count'=>0
];
foreach ($list as $item) {
if($item['date'] == $i){
$dates[$k]=[
'date'=>$i,
'xingqi'=>$xingqi,
'count'=>$item['count']
];
break;
}
}
$k++;
}
return \Yz::Return(true,"查询完成",['list'=>$dates]);
}
//核磁当日号源
public function GetDayPlanList()
{
$hospital_id =request('hospital');
$date=request('date');
// 获取前后各三天的日期
$dateTime = new DateTime($date);
$days7=[];
for ($i = -3; $i <= 3; $i++) {
$dateTimeClone = clone $dateTime; // 克隆对象以避免修改原对象
$dateTimeClone->modify("$i days"); // 修改日期
$days7[] = $dateTimeClone->format('Y-m-d'); // 按照需要的格式添加到结果数组
}
$aspnet=new AspNetZhuanController();
$week7=[];
$currentDate = new DateTime();
$nmr=$aspnet::ErXian(['yyid'=>6,'data'=>$days7,'action'=>"1"],uniqid());
//获取每日数量
foreach($nmr as $k=>$v){
$t_v=[];
foreach ($v as $k1 => $v1) {
$givenDate = new DateTime($v1['DTime']);
if($v1['keyong']==0 and $givenDate > $currentDate){
$t_v[]=$v1;
}
}
$xingqi=\App\Lib\Tools::GetWeekName($k);
$week7[]=[
'date'=>$k,
'count'=>count($t_v),
'xingqi'=>$xingqi
];
}
$list=[];
if(isset($nmr[$date])){
foreach($nmr[$date] as $k=>$v){
$givenDate = new DateTime($v['DTime']);
if($givenDate > $currentDate){
$list[]=[
'id'=>$v['TimeNum'],
'time'=>$v['Time'],
'status'=>$v['keyong']==="0"?1:2,
];
}
}
}
// $list=[
// [
// 'id'=>1,
// 'status'=>1,
// 'time'=>'10:15'
// ],
// [
// 'id'=>1,
// 'status'=>1,
// 'time'=>'10:45'
// ]
// ];
// $week7=[];
// $k=0;
// foreach ($days7 as $date) {
// $xingqi=\App\Lib\Tools::GetWeekName($date);
// $week7[]=[
// 'date'=>$date,
// 'count'=>0,
// 'xingqi'=>$xingqi
// ];
// foreach ($weeklist as $plan) {
// if($plan['date'] == $date){
// $week7[$k]=[
// 'date'=>$date,
// 'xingqi'=>$xingqi,
// 'count'=>$plan['count']
// ];
// break;
// }
// }
// $k++;
// }
return \Yz::Return(true,"查询完成",['list'=>$list,'weeklist'=>$week7]);
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,146 @@
<?php
namespace App\Http\Controllers\API\H5;
use App\Http\Controllers\API\AspNetZhuanController;
use App\Http\Controllers\API\XCXApiController;
use App\Http\Controllers\Controller;
use App\Services\OrderService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class PayController extends Controller
{
//支付回调.弃用!!!!
public function Notify()
{
$order_num = request('order_num');
$status = request('status');
$pay_info = request('pay_info');
if (!isset($order_num)) return \Yz::echoError1("订单号不能为空");
$order = DB::table('orders')->where(['order_number' => $order_num])->first();
if (!$order) return \Yz::echoError1("订单不存在");
if ($status == 'SUCCESS') {
$u = DB::table('orders')->where(['order_number' => $order_num])->update([
'status' => 2
]);
if ($u) {
return \Yz::Return(true, "更新成功", ['order_num' => $order_num]);
}
}
}
//对参数进行签名,返回前端需要的参数,前端携带参数跳转小程序支付
public function StartPay()
{
$openid = request('openid');
$id = request('id');
if(!isset($id)) return \Yz::echoError1("id不能为空");
$orderInfo = DB::table('orders')->where(['id' => $id,])->first();
if (!$orderInfo) return \Yz::echoError1("未找到有效订单");
if ($orderInfo->status !== 1) return \Yz::echoError1("订单不是待支付状态不能支付。当前状态:" . $orderInfo->status);
$personInfo = DB::table('web_user_person')->where(['id' => $orderInfo->person_id, 'is_del' => 0])->first();
if (!$personInfo) return \Yz::echoError1("就诊人异常");
$sub_org_code = 0; //小程序端医院代码
if ($orderInfo->hospital_id == 1) {
$sub_org_code = 6;
}
if ($orderInfo->hospital_id == 2) {
$sub_org_code = 2;
}
if ($sub_org_code == 0) return \Yz::echoError1("医院id异常");
//每次支付前更新订单号为1个新订单号码
$randomPart = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 6);
$new_ordernumber=substr($orderInfo->order_number, 0, -6);
$new_ordernumber=$new_ordernumber.$randomPart;
$u=DB::table('orders')->where(['id' => $id,])->update(['order_number'=>$new_ordernumber]);
if(!$u) return \Yz::echoError1("更新订单号失败");
$XCXApi = new XCXApiController();
$params = [
'appid' => $XCXApi::$appid,
'sub_org_code' => $sub_org_code,
'ghzid' => $personInfo->ghzid,
'orderid' => $new_ordernumber,
'order_desc' => $orderInfo->title,
'amount' => (int)($orderInfo->true_price * 100),
'notify_url' => config('app.globals.PayNotifyUrl')
];
$nonce = self::nonce();
$timestamp = (string)time();
//签名
$pay_path = "/jeecg-boot/hospital/openapi/order/create";
$base64Signature = $XCXApi::Sign($pay_path, $params, $nonce, $timestamp, true);
$params['timestamp'] = $timestamp;
$params['nonce'] = $nonce;
$params['signature'] = $base64Signature;
return \Yz::Return(true, "操作完成", ['info' => $params]);
}
//订单支付查询
public function CheckPay()
{
$openid = request('openid');
$order_number = request('order_number');
$XCX = new XCXApiController();
$res = $XCX::Post('订单查询', ['orderid' => $order_number]);
//判断如果支付成功,更改订单状态
if ($res['data']['trade_state'] === 'SUCCESS') {
$order = DB::table('orders')->where(['order_number' => $order_number])->first();
if($order->status == 1){
DB::table('orders')->where(['id' => $order->id])->update([
'status' => 2,
'pay_time' => date('Y-m-d H:i:s'),
]);
$Finish = new OrderController();//预约体检
$Finish->Finish($order_number);
}
return \Yz::Return(true, "支付成功", ['id' => $order->id]);
} else {
return \Yz::echoError1("支付失败" . $res['data']['trade_state']);
}
}
//退款
public function Refund()
{
//先调用思信取消,恢复号源,然后再退款
//判断订单状态是否是已经支付,判断是否到检,
$openid = request('openid');
$id = request('id');
if(!isset($id)) return \Yz::echoError1("id不能为空");
$orderInfo = DB::table('orders')->where(['id' => $id,])->first();
if(!$orderInfo) return \Yz::echoError1("未找到有效订单");
$userInfo = DB::table('web_users')->where(['id' => $orderInfo->web_user_id])->first();
if($openid != $userInfo->openid) return \Yz::echoError1("无权操作此订单");
$service = new OrderService();
$res=$service->Refund($id);
if(!$res['status']) return \Yz::echoError1($res['msg']);
if($res['status']) return \Yz::Return(true, "退款成功", []);
}
//机器人退款
public function AutoRefund(){
$id = request('id');
$key = request('key');
if($key != "dfsd2Ajd256SDI02") return \Yz::echoError1("权限校验错误");
if(!isset($id)) return \Yz::echoError1("id不能为空");
$service = new OrderService();
$res=$service->Refund($id);
if(!$res['status']) return \Yz::echoError1($res['msg']);
if($res['status']) return \Yz::Return(true, "自动退款成功", []);
}
public static function nonce($l = 16)
{
$charts = "ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz0123456789";
$max = strlen($charts) - 1;
$noncestr = "";
for ($i = 0; $i < $l; $i++) {
$noncestr .= $charts[rand(0, $max)];
}
return $noncestr;
}
}

@ -0,0 +1,160 @@
<?php
namespace App\Http\Controllers\API\H5;
use App\Http\Controllers\API\PEISApiController;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class PersonController extends Controller
{
public function group_info($hospital, $data)
{
$peis = new PEISApiController();
$info = $peis::Post('团检登记查询', $hospital, $data);
$group_list=[];
foreach ($info['data'] as $it) {
$items = [];
$duoxuan_yi=[];
$group_info = $it;
if (isset($group_info['项目列表'])) {
foreach ($group_info['项目列表'] as $datum) {
$items[] = [
'id' => $datum['Id'],
'name' => $datum['名称'],
];
}
}
if(isset($group_info['单位Id']) and !empty($group_info['单位Id']) and isset($group_info['分组Id']) and !empty($group_info['分组Id'])){
$items=[];
$peis = new PEISApiController();
$data=[
"单位Id"=>$group_info['单位Id']
];
$fenzu = $peis::Post('单位分组批次查询', 1, $data);
// Log::info(json_encode($fenzu,JSON_UNESCAPED_UNICODE));
if(empty($fenzu['data'])) break;
foreach ($fenzu['data'][0]['分组'] as $key => $value) {
if($value['Id']==$group_info['分组Id']){
$group_info['总计金额']=$value['价格'];
if (isset($value['包含项目信息'])) {
foreach ($value['包含项目信息'] as $datum) {
$items[] = [
'id' => $datum['Id'],
'name' => $datum['名称'],
];
}
}
if(isset($value['包含多选一组'])){
//多选一
$duo_xuan_yi=[];
$N1=$value['包含多选一组'];
foreach ($N1 as $k=>$v){
$duo_xuan_yi[$k][]=[
'zu_name'=>$v['组名称'],
'item_list'=>[]
];
foreach ($v['包含项目'] as $k2=>$v2){
$duo_xuan_yi[$k]['item_list'][]=
[
'item_id' =>$v2['Id'],
'item_name' => $v2['名称'],
'price'=>$v2['价格']
];
}
}
$duoxuan_yi= $duo_xuan_yi;
}
break;
}
}
}
$checkup_type=DB::table('checkup_type')->where(['status'=>1,'is_del'=>0])->get();
$checkup_type_id=0;
foreach ($checkup_type as $ct) {
if($group_info['体检类型']==$ct->name){
$checkup_type_id=$ct->id;
}
}
$data=[
'name' => $group_info['姓名'],
'id_number' => $group_info['证件号码'],
'combo_name' => $group_info['套餐名称'],
'combo_id' => $group_info['套餐Id'],
'start_time' => $group_info['预约开始日期'],
'end_time' => $group_info['预约结束日期'],
'group_name' => $group_info['单位名称'] . ($group_info['部门名称']),
'bumen_name' => $group_info['部门名称'],
'group_id' => $group_info['预约Id'],
'tongshou_xiane'=>$group_info['统收限额']==0?0.00:$group_info['统收限额'],
'sixi_zong_ji_jin_e'=>$group_info['总计金额'],
'danwei_id'=>$group_info['单位Id'],
'fenzu_id'=>$group_info['分组Id'],
'checkup_type_id'=>$checkup_type_id,
'items' => $items,
'duo_xuan_yi'=>$duoxuan_yi,
];
$group_list[]=$data;
}
return $group_list;
}
//团检登记查询根据身份证和电话查分组id
public function GetGroupUnit()
{
$phone = request('phone');
$id_number = request('id_number');
$hospital_id = request('hospital_id');
if (!isset($phone)) return \Yz::echoError1('电话不能为空');
if (!isset($id_number)) return \Yz::echoError1('身份证不能为空');
if (!isset($hospital_id)) return \Yz::echoError1('医院id不能为空');
$data = [
'电话号码' => $phone,
'证件号码' => $id_number
];
$res = self::group_info($hospital_id, $data);
$dbinfo=DB::table('web_user_person')->where(['phone'=>$phone,'id_number'=>$id_number])->first();
if(!!$dbinfo){
foreach ($res as $key => $value) {
//dd($res[$key]);
$res[$key]['sex']=$dbinfo->sex;
$res[$key]['phone']=$dbinfo->phone;
$res[$key]['married']=$dbinfo->married ;
}
}
return \Yz::Return(true,"查询完成",['unit'=>$res]);
}
//获取团检套餐
public function GetGroupCombo()
{
$hospital_id = request('hospital_id');
$group_id = request('group_id');
if (!isset($group_id)) return \Yz::echoError1('group_id不能为空');
$data = [
'电话号码' => null,
'证件号码' => null,
'预约Id'=>$group_id
];
$res = self::group_info($hospital_id, $data);
if($res[0]['fenzu_id']=="") return \Yz::echoError1("用户分组不能为空");
return \Yz::Return(true,"查询完成",['unit'=>$res]);
}
}

@ -0,0 +1,240 @@
<?php
namespace App\Http\Controllers\API\H5;
use App\Http\Controllers\Controller;
use DateTime;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class PlanController extends Controller
{
//获取本月每日剩余号源数量
public function GetMonthPlanCount()
{
$hospital_id =request('hospital');
$openid =request('openid');
$person_id=request('person_id');
$month=request('month');
$use_type=request('use_type');//使用类型 1个检 2团检
$checkup_type_id=request('checkup_type_id');//体检类型表对应id
$amount=request('amount');//总金额
if(!isset($checkup_type_id)) return \Yz::echoError1("体检类型不能为空");
$first_day_timestamp = strtotime($month . '-01');
$first_day = date('Y-m-d', $first_day_timestamp); //当月第一天
$last_day_timestamp = strtotime($month . '-01 +1 month -1 day');
$last_day = date('Y-m-d', $last_day_timestamp); //当月最后一天
$currentDateTime = now();
$list=DB::table('plans')
->whereBetween('date',[$first_day,$last_day])->whereIn('status',[1])
->whereRaw('CONCAT(date, " ", time) >?', [$currentDateTime])
->whereRaw('JSON_CONTAINS(checkup_type_id, ?, "$")', [json_encode($checkup_type_id)])
->where(['hospital_id'=>$hospital_id,'type'=>1,'is_del'=>0])
->where('is_vip','<>',1)
->whereIn('use_type',[0,$use_type]);
if(isset($person_id)){
$personInfo=DB::table('web_user_person')->where(['id'=>$person_id])->first();
if(!!$personInfo){
$list=$list->whereIn('sex',[0,$personInfo->sex]);
}
}
if ($use_type == 1) {
$list = $list->where(function ($query) use ($amount) {
$query->where('amount_limit1', 0)->orWhere('amount_limit1', '>=', $amount);
});
}
if ($use_type == 2) {
$list = $list->where(function ($query) use ($amount) {
$query->where('amount_limit2', 0)->orWhere('amount_limit2', '>=', $amount);
});
}
$list=$list->select('date', DB::raw('COUNT(*) as count'));
$list=$list->groupBy('date')->get();
//获取整月日期
// 获取当月的第一天
$firstDay = date("Y-m-d", strtotime($month . "-01"));
// 获取当月的最后一天
$lastDay = date("Y-m-t", strtotime($month));
$dates = array();
$k=0;
for ($i = $firstDay; $i <= $lastDay; $i = date("Y-m-d", strtotime($i . " +1 day"))) {
$xingqi=\App\Lib\Tools::GetWeekName($i);
$dates[]=[
'date'=>$i,
'xingqi'=>$xingqi,
'count'=>0
];
foreach ($list as $item) {
if($item->date == $i){
$dates[$k]=[
'date'=>$i,
'xingqi'=>$xingqi,
'count'=>$item->count
];
break;
}
}
$k++;
}
return \Yz::Return(true,"查询完成",['list'=>$dates]);
}
//获取某日号源列表
public function GetDayPlanList()
{
$hospital_id =request('hospital');
$openid =request('openid');
$person_id=request('person_id');
$person_sex=request('person_sex');
$combo_id=request('combo_id');
$date=request('date');
$use_type=request('use_type');//使用类型 1个检 2团检
$checkup_type_id=(string)request('checkup_type_id');//体检类型表对应id
$amount=request('amount');//总金额
if(!isset($checkup_type_id)) return \Yz::echoError1("体检类型不能为空");
$personInfo=false;
if(isset($person_id)){
$personInfo=DB::table('web_user_person')->where(['id'=>$person_id])->first();
}
$currentDateTime = now();
$list=DB::table('plans')
->where('date',$date)->whereIn('status',[1,2])
->whereRaw('CONCAT(date, " ", time) >?', [$currentDateTime])
->whereRaw('JSON_CONTAINS(checkup_type_id, ?, "$")',[$checkup_type_id])
->where(['hospital_id'=>$hospital_id,'type'=>1,'is_del'=>0])
->where('is_vip','<>',1)
->whereIn('use_type',[0,$use_type]);
if(!!$combo_id){
$comboInfo=DB::table('combos')->where(['combo_id'=>$combo_id])->first();
if(!empty($comboInfo->keyue_start_time) and !empty($comboInfo->keyue_end_time)){
$list=$list->whereBetween('time',[$comboInfo->keyue_start_time,$comboInfo->keyue_end_time]);
}
}
if(!!$personInfo){
$list=$list->whereIn('sex',[0,$personInfo->sex]);
}
if(isset($person_sex)){
$list=$list->whereIn('sex',[0,$person_sex]);
}
if ($use_type == 1) {
$list = $list->where(function ($query) use ($amount) {
$query->where('amount_limit1', 0)->orWhere('amount_limit1', '>=', $amount);
});
}
if ($use_type == 2) {
$list = $list->where(function ($query) use ($amount) {
$query->where('amount_limit2', 0)->orWhere('amount_limit2', '>=', $amount);
});
}
$list=$list->orderBy('time','asc')->get();
// 获取前后各三天的日期
$dateTime = new DateTime($date);
$days7=[];
for ($i = -3; $i <= 3; $i++) {
$dateTimeClone = clone $dateTime; // 克隆对象以避免修改原对象
$dateTimeClone->modify("$i days"); // 修改日期
$days7[] = $dateTimeClone->format('Y-m-d'); // 按照需要的格式添加到结果数组
}
$weeklist=DB::table('plans')
->whereBetween('date',[$days7[0],$days7[6]])->whereIn('status',[1])
->whereRaw('CONCAT(date, " ", time) >?', [$currentDateTime])
->whereRaw('JSON_CONTAINS(checkup_type_id, ?, "$")', [$checkup_type_id])
->where(['hospital_id'=>$hospital_id,'type'=>1,'is_del'=>0])
->where('is_vip','<>',1)
->whereIn('use_type',[0,$use_type]);
if(!!$combo_id){
$comboInfo=DB::table('combos')->where(['combo_id'=>$combo_id])->first();
if(!empty($comboInfo->keyue_start_time) and !empty($comboInfo->keyue_end_time)){
$weeklist=$weeklist->whereBetween('time',[$comboInfo->keyue_start_time,$comboInfo->keyue_end_time]);
}
}
if(!!$personInfo){
$weeklist=$weeklist->whereIn('sex',[0,$personInfo->sex]);
}
if ($use_type == 1) {
$weeklist = $weeklist->where(function ($query) use ($amount) {
$query->where('amount_limit1', 0)->orWhere('amount_limit1', '>=', $amount);
});
}
if ($use_type == 2) {
$weeklist = $weeklist->where(function ($query) use ($amount) {
$query->where('amount_limit2', 0)->orWhere('amount_limit2', '>=', $amount);
});
}
$weeklist=$weeklist->select('date', DB::raw('COUNT(*) as count'));
$weeklist=$weeklist->groupBy('date')->get();
$week7=[];
$k=0;
foreach ($days7 as $date) {
$xingqi=\App\Lib\Tools::GetWeekName($date);
$week7[]=[
'date'=>$date,
'count'=>0,
'xingqi'=>$xingqi
];
foreach ($weeklist as $plan) {
if($plan->date == $date){
$week7[$k]=[
'date'=>$date,
'xingqi'=>$xingqi,
'count'=>$plan->count
];
break;
}
}
$k++;
}
return \Yz::Return(true,"查询完成",['list'=>$list,'weeklist'=>$week7]);
}
//检查号源是否可用
public function CheckPlan($plan_id,$hospital_id,$type,$sex,$price,$checkup_type_id)
{
$plan = DB::table('plans')->where(['id' => $plan_id, 'hospital_id' => $hospital_id, 'status' => 1, 'is_del' => 0])->first();
if (!$plan) return ['status'=>false,'msg'=>"号源不可用"];
//判断个检/团检类型
if ($plan->use_type <> 0 and $plan->use_type <> $type) {
$type_temp = '';
if ($plan->use_type == 1) $type_temp = '个检';
if ($plan->use_type == 2) $type_temp = '团检';
return ['status'=>false,'msg'=>"此号源为" . $type_temp . "号源,不可用"];
}
//判断是否是预留号源
if ($plan->type <> 1) return ['status'=>false,'msg'=>"此号源为预留号源,不可用"];
//判断是否是vip
//判断性别
if ($plan->sex <> 0 and $plan->sex <> $sex) return ['status'=>false,'msg'=>"此号源性别与体检人性别不符,不可用"];
//判断体检类型checkup_type
if(!!$checkup_type_id){
$checkup_type_array=json_decode($plan->checkup_type_id,true);
if(!in_array($checkup_type_id,$checkup_type_array)){
return ['status'=>false,'msg'=>"此号源体检类型与套餐不匹配,不可用"];
}
}
//判断金额
if ($plan->use_type == 1 and $plan->amount_limit1 <> 0) {
if ($price < $plan->amount_limit1) return ['status'=>false,'msg'=>"未达到此号源限制的金额,不可用"];
}
if ($plan->use_type == 2 and $plan->amount_limit2 <> 0) {
if ($price < $plan->amount_limit2) return ['status'=>false,'msg'=>"未达到此号源限制的金额,不可用"];
}
//判断时间是否过期
$plan_datetime = $plan->date . ' ' . $plan->time;
if ($plan_datetime < date('Y-m-d H:i:s')) return ['status'=>false,'msg'=>"号源已过期,不可用"];
return ['status'=>true,'msg'=>"",'plan'=>$plan];
}
}

@ -0,0 +1,87 @@
<?php
namespace App\Http\Controllers\API\H5;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class QuestionController extends Controller
{
public function GetList()
{
$hospital_id = request('hospital_id');
$q_type = request('q_type');
$person= request('person');
$count=0;
if (!isset($hospital_id)) return \Yz::echoError1("医院id不能为空");
if (!isset($q_type)) return \Yz::echoError1("问卷类型不能为空");
$list = DB::table('questions')
->where(['hospital_id'=>$hospital_id,
'q_type'=>$q_type,
'status'=>1,
'is_del'=>0,
])->orderBy('order','asc')->get();
foreach ($list as $key=>$item){
$item->content=json_decode($item->content,true);
if($person['sex']==1 and strpos($item->question, '女性') !== false){
$item->show=false;
}else{
$item->show=true;
$count++;
}
}
return \Yz::Return(true,"查询成功",['list'=>$list,'count'=>$count]);
}
//提交调查
public function SubmitAnswer()
{
$openid = request('openid');
$content = request('content');
$q_type = request('q_type');
$user = DB::table('web_users')->where(['openid' => $openid, 'status' => 1, 'is_del' => 0])->first();
if (!$user) return \Yz::echoError1('用户不存在');
if(!isset($q_type)) return \Yz::echoError1('问卷类型不能为空');
if(!isset($content) or empty($content)) return \Yz::echoError1('内容不能为空');
$person=DB::table('web_user_person')->where(['user_id' => $user->id, 'is_del' => 0])->orderBy('is_default')->get();
if(count($person)==0){
return \Yz::echoError1('请先绑定就诊人');
}
$data=[
'userid'=>$user->id,
'personid'=>$person[0]->id,
'q_type'=>$q_type,
'content'=>json_encode($content,JSON_UNESCAPED_UNICODE)
];
$i=DB::table('questions_log')->insert($data);
if($i){
return \Yz::Return(true,"提交成功",[]);
}else{
return \Yz::echoError1('提交失败');
}
}
public function HunQianQuestionSubmit()
{
$openid = request('openid');
$person_id = request('person_id');
$content = request('content');
$user = DB::table('web_users')->where(['openid' => $openid, 'status' => 1, 'is_del' => 0])->first();
if (!$user) return \Yz::echoError1('用户不存在');
$data=[
'userid'=>$user->id,
'personid'=>$person_id,
'q_type'=>3,
'content'=>!empty($content)?json_encode($content,JSON_UNESCAPED_UNICODE):[]
];
$i=DB::table('questions_log')->insert($data);
if($i){
return \Yz::Return(true,"提交成功",[]);
}else{
return \Yz::echoError1('提交失败');
}
}
}

@ -0,0 +1,121 @@
<?php
namespace App\Http\Controllers\API\H5;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class QuestionnaireController extends Controller
{
public function list(Request $request)
{
$db = DB::table('question_lists');
$question = $db->orderBy('order', 'desc')->get();
$list = [];
foreach ($question as $key => $value) {
$list[] = [
'id' => $value->question,
'title' => $value->name,
'icon' => $value->icon,
'desc' => $value->desc,
];
}
return \Yz::Return(true, '操作完成', [
'list' => $list
]);
}
public function get(Request $request)
{
$id = $request->post('id');
$person = $request->post('person');
$question = DB::table('questionnaires')->where('id', $id)->first();
if (!$question) {
return \Yz::echoError('问卷不存在');
}
$question_ids = json_decode($question->questions, true);
$person_info = DB::table('web_user_person')->where('id', $person)->first();
$list = self::getList($person_info, $question_ids);
return \Yz::Return(true, '操作完成', [
'info' => $question,
'list' => $list
]);
}
public function getList($person, $ids, $level = 0)
{
$list = [];
$replace_array = ['name', 'birthday', 'phone', 'id_number'];
foreach ($ids as $id) {
$question = DB::table('question_questions')->where('id', $id)->first();
if (!!$question) {
if ($level < 3) {
$question->option = json_decode($question->option, true);
$item_data = [
'id' => $question->id,
'type' => $question->type,
'question' => $question->question,
'value' => '',
];
if (in_array($question->type, ['input', 'date', 'city'])) {
$v = $question->option['input']['value'];
$item_data['value'] = $v;
$item_data['placeholder'] = $question->option['input']['placeholder'];
} else {
if($question->question=='性别'){
if($person->sex==1) $vl=0;
if($person->sex==2) $vl=1;
}else{
$vl='';
}
$item_data['value'] = $vl;
$select = $question->option['select']['value'];
$select_array = [];
foreach ($select as $select_value) {
$push_item = [
'content' => $select_value['content'],
'children' => []
];
if ($select_value['type'] == 'questions') {
$children = self::getList($person, $select_value['questions'], $level + 1);
if (count($children) > 0) {
$push_item['children'] = $children;
}
}
$select_array[] = $push_item;
}
$item_data['select'] = $select_array;
}
$v = $item_data['value'];
foreach ($replace_array as $replace_item) {
if (!!$person) {
$v = str_replace('${' . $replace_item . '}', $person->$replace_item, $v);
} else {
$v = str_replace('${' . $replace_item . '}', '', $v);
}
}
$v = str_replace('${体重}', '', $v);
$v = str_replace('${身高}', '', $v);
$v = str_replace('${今日日期}',$person->birthday , $v);
if ($v == '${省市县}') {
$v = [[
'value' => '11',
'text' => '北京市'
], [
'value' => '1101',
'text' => '市辖区'
], [
'value' => '110101',
'text' => '东城区'
]];
}
$item_data['value'] = $v;
$list[] = $item_data;
}
}
}
return $list;
}
}

@ -0,0 +1,415 @@
<?php
namespace App\Http\Controllers\API\H5;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class QuestionnairesLogsController extends Controller
{
public function delete(Request $request)
{
$id = $request->post('id');
$person_id = $request->post('person');
$person_info = DB::table('web_user_person')->where('id', $person_id)->first();
if (!$person_info) {
return \Yz::echoError('人员信息不存在');
}
$log_info = DB::table('questionnaires_logs')->where('id', $id)->where('person_id', $person_id)->first();
if (!$log_info) {
return \Yz::echoError('问卷信息不存在');
}
DB::table('questionnaires_logs')->where('id', $id)->update(['del' => 1]);
return \Yz::Return(true, '操作完成');
}
public function list(Request $request)
{
$person_id = $request->post('person');
$person_info = DB::table('web_user_person')->where('id', $person_id)->first();
if (!$person_info) {
return \Yz::echoError('人员信息不存在');
}
$log = DB::table('questionnaires_logs')->select(['*'])
->selectRaw("IFNULL((select `name` from questionnaires where questionnaires.id = questionnaires_logs.person_id),'') as title")
->where('items', '!=', '[]')
->where('person_id', $person_id)
->where('del', 2)
->orderBy('id', 'desc')->get();
$list = [];
foreach ($log as $value) {
$person_info = json_decode($value->person_info, true);
$age = !!$person_info['birthday'] ? date('Y') - date('Y', strtotime($person_info['birthday'])) : 0;
$check_items = json_decode($value->check_items, true);
$count = count($check_items);
$list[] = [
'id' => $value->id,
'title' => $value->title,
'name' => $person_info['name'],
'age' => $age,
'created_at' => $value->created_at,
'count' => $count
];
}
return \Yz::Return(true, '操作完成', [
'log'=>$log,
'list' => $list,
]);
}
public function push(Request $request)
{
$id = $request->post('id');
$person_id = $request->post('person');
$person_info = DB::table('web_user_person')->where('id', $person_id)->first();
if (!$person_info) {
return \Yz::echoError('人员信息不存在');
}
$log_info = DB::table('questionnaires_logs')->where('question_id', $id)->where('person_id', $person_id)->orderBy('id', 'desc')->first();
if (!$log_info) {
return \Yz::echoError('未查询到答题记录');
}
$content = json_decode($log_info->content, true);
return \Yz::Return(true, '操作完成', [
'info' => $content,
]);
}
public function info(Request $request)
{
$id = $request->post('id');
$person_id = $request->post('person');
$person_info = DB::table('web_user_person')->where('id', $person_id)->first();
if (!$person_info) {
return \Yz::echoError('人员信息不存在');
}
$log_info = DB::table('questionnaires_logs')->where('id', $id)->where('person_id', $person_id)->first();
if (!$log_info) {
return \Yz::echoError('问卷信息不存在');
}
$person_info = json_decode($log_info->person_info, true);
$age = !!$person_info['birthday'] ? date('Y') - date('Y', strtotime($person_info['birthday'])) : 0;
$sex = !!$person_info['sex'] ? $person_info['sex'] : 1;
$weight = !!$log_info->weight ? $log_info->weight : 0;
$height = !!$log_info->height ? $log_info->height : 0;
$items_ids = json_decode($log_info->check_items, true);
$check_items = [];
if (!!count($items_ids)) {
$items_info = DB::table('question_items')->whereIn('id', $items_ids)->get();
foreach ($items_info as $key => $value) {
$check_items[] = [
'id' => $value->id,
'name' => $value->name,
];
}
}
$items = json_decode($log_info->items, true);
$check_items_array = json_decode($log_info->check_items_array, true);
$wh = '-';
if (!!$weight && $height) {
$wh = round($weight / pow($height / 100, 2), 2);
}
return \Yz::Return(true, '操作完成', [
'date' => date('Y-m-d', strtotime($log_info->created_at)),
'sex' => $sex,
'age' => $age,
'weight' => $wh,
'items' => $items,
'check_items' => $check_items,
'check_items_array' => $check_items_array,
'price' => [
'jichu' => self::sum_items($items, $check_items_array['jichu']),
'tuijian' => self::sum_items($items, $check_items_array['tuijian']),
'gaoduan' => self::sum_items($items, $check_items_array['gaoduan']),
],
'original_price' => [
'jichu' => self::sum_items($items, $check_items_array['jichu'], false),
'tuijian' => self::sum_items($items, $check_items_array['tuijian'], false),
'gaoduan' => self::sum_items($items, $check_items_array['gaoduan'], false),
],
'count' => [
'jichu' => self::item_count($items, $check_items_array['jichu']),
'tuijian' => self::item_count($items, $check_items_array['tuijian']),
'gaoduan' => self::item_count($items, $check_items_array['gaoduan']),
]
]);
}
public function item_count($items, $check_items)
{
if (count($items)) {
$items_count = DB::table('items')->whereIn('item_id', $items)
->where('keshi_name', '!=', '材料费')->where('status', 1)->count();
} else {
$items_count = 0;
}
if (count($check_items['items'])) {
$check_sum_count = DB::table('items')
->whereIn('item_id', $check_items['items'])
->where('keshi_name', '!=', '材料费')->where('status', 1)->count();
} else {
$check_sum_count = 0;
}
if (count($check_items['combo_items'])) {
$combo_count = DB::table('items')
->whereIn('item_id', $check_items['combo_items'])
->where('keshi_name', '!=', '材料费')->where('status', 1)->count();
} else {
$combo_count = 0;
}
$ic = $items_count + $check_sum_count + $combo_count;
return $ic;
}
public function sum_items($items, $check_items, $zk = true)
{
if (count($items)) {
$sum = DB::table('items')->whereIn('item_id', $items)->where('status', 1)->sum('price');
} else {
$sum = 0;
}
if (count($check_items['items'])) {
$check_sum = DB::table('items')->whereIn('item_id', $check_items['items'])->where('status', 1)->sum('price');
} else {
$check_sum = 0;
}
if (count($check_items['combo_items'])) {
$combo = DB::table('items')->whereIn('item_id', $check_items['combo_items'])->where('status', 1)->sum('price');
} else {
$combo = 0;
}
if (!!$zk) {
$zhekou = config('app.globals.Wj_ZheKou');
} else {
$zhekou = 1;
}
return number_format((($combo + $sum + $check_sum) * $zhekou), 2, '.', '');
}
public function submit(Request $request)
{
$question_id = $request->post('question_id');
$content = $request->post('content');
$use_time = $request->post('use_time');
$question_info = DB::table('questionnaires')->where('id', $question_id)->first();
if (!$question_info) {
return \Yz::echoError('问卷不存在');
}
$person_id = $request->post('person_id');
$person_info = DB::table('web_user_person')->where('id', $person_id)->first();
if (!$person_info) {
return \Yz::echoError('人员信息不存在');
}
$type = $question_info->type;
$items = json_decode($question_info->items, true);
$check_items = [];
$check_items_array = [
'jichu' => [
'combo' => '0',
'combo_items' => [],
'items' => []
],
'tuijian' => [
'combo' => '0',
'combo_items' => [],
'items' => []
],
'gaoduan' => [
'combo' => '0',
'combo_items' => [],
'items' => []
],
];
$question_ids = [];
$question_map = [];
foreach ($content as $key => $value) {
$question_ids[] = $value['id'];
$question_map["q{$value['id']}"] = $value;
}
if (!!count($question_ids)) {
$question_questions = DB::table('question_questions')->whereIn('id', $question_ids)->get();
} else {
$question_questions = [];
}
$weight = 0;
$height = 0;
$score = 0;
foreach ($question_questions as $value) {
$id = $value->id;
$option = json_decode($value->option, true);
if (in_array($value->type, ['input', 'date', 'city'])) {
if ($option['input']['value'] === '${体重}') {
if (isset($question_map["q{$id}"])) {
$weight = $question_map["q{$id}"]['value'];
}
}
if ($option['input']['value'] === '${身高}') {
if (isset($question_map["q{$id}"])) {
$height = $question_map["q{$id}"]['value'];
}
}
} else {
if (isset($question_map["q{$id}"])) {
$v = $question_map["q{$id}"]['active'];
$item_option = $option['select']['value'][$v];
if ($item_option['type'] === 'score') {
if (!isset($item_option['score'])) {
$item_option['score'] = 0;
}
foreach ($content as $content_key => $content_item) {
if ($content_item['id'] == $id) {
$content[$content_key]['score'] = $item_option['score'];
}
}
$score = $score + $item_option['score'];
}
if ($item_option['type'] === 'items') {
foreach ($item_option['items'] as $item) {
if (!in_array($item, $check_items)) {
$check_items_info = DB::table('question_items')->where('id', $item)->first();
if (!!$check_items_info) {
$check_items[] = (string)$item;
if ($check_items_info->jichu != '0') {
$jichu_combo_info = DB::table('combos')->where('combo_id', $check_items_info->jichu)->first();
if (!!$jichu_combo_info) {
if ($check_items_array['jichu']['combo'] == '0') {
$items_ids = [];
$combo_items = json_decode($jichu_combo_info->items, true);
foreach ($combo_items as $combo_item) {
$items_ids[] = $combo_item['id'];
}
$check_items_array['jichu']['combo'] = $check_items_info->jichu;
$check_items_array['jichu']['combo_items'] = $items_ids;
} else {
$items_ids = [];
$combo_items = json_decode($jichu_combo_info->items, true);
foreach ($combo_items as $combo_item) {
if (
!in_array($combo_item['id'], $check_items_array['jichu']['combo_items']) &&
!in_array($combo_item['id'], $check_items_array['jichu']['items'])
) {
$items_ids[] = $combo_item['id'];
}
}
$check_items_array['jichu']['items'] = array_merge($check_items_array['jichu']['items'], $items_ids);
}
}
}
if ($check_items_info->tuijian != '0') {
$tuijian_combo_info = DB::table('combos')->where('combo_id', $check_items_info->tuijian)->first();
if (!!$tuijian_combo_info) {
if ($check_items_array['tuijian']['combo'] == '0') {
$items_ids = [];
$combo_items = json_decode($tuijian_combo_info->items, true);
foreach ($combo_items as $combo_item) {
$items_ids[] = $combo_item['id'];
}
$check_items_array['tuijian']['combo'] = $check_items_info->tuijian;
$check_items_array['tuijian']['combo_items'] = $items_ids;
} else {
$items_ids = [];
$combo_items = json_decode($tuijian_combo_info->items, true);
foreach ($combo_items as $combo_item) {
if (
!in_array($combo_item['id'], $check_items_array['tuijian']['combo_items']) &&
!in_array($combo_item['id'], $check_items_array['tuijian']['items'])
) {
$items_ids[] = $combo_item['id'];
}
}
$check_items_array['tuijian']['items'] = array_merge($check_items_array['tuijian']['items'], $items_ids);
}
}
}
if ($check_items_info->gaoduan != '0') {
$gaoduan_combo_info = DB::table('combos')->where('combo_id', $check_items_info->gaoduan)->first();
if (!!$gaoduan_combo_info) {
if ($check_items_array['gaoduan']['combo'] == '0') {
$items_ids = [];
$combo_items = json_decode($gaoduan_combo_info->items, true);
foreach ($combo_items as $combo_item) {
$items_ids[] = $combo_item['id'];
}
$check_items_array['gaoduan']['combo'] = $check_items_info->gaoduan;
$check_items_array['gaoduan']['combo_items'] = $items_ids;
} else {
$items_ids = [];
$combo_items = json_decode($gaoduan_combo_info->items, true);
foreach ($combo_items as $combo_item) {
if (
!in_array($combo_item['id'], $check_items_array['gaoduan']['combo_items']) &&
!in_array($combo_item['id'], $check_items_array['gaoduan']['items'])
) {
$items_ids[] = $combo_item['id'];
}
}
$check_items_array['gaoduan']['items'] = array_merge($check_items_array['gaoduan']['items'], $items_ids);
}
}
}
}
}
}
}
}
}
}
preg_match_all('/\d+/', $weight, $matches);
$weight = $matches[0][0];
$weight = $weight ? $weight : 0;
preg_match_all('/\d+/', $height, $matches);
$height = $matches[0][0];
$height = $height ? $height : 0;
$ip = self::getTrustedProxiesIp();
$ip2region = new \Ip2Region();
$record = $ip2region->simple($ip);
$ip_info = '';
if (!!$record) {
$ip_info = $record;
}
$log_id = DB::table('questionnaires_logs')->insertGetId([
'question_id' => $question_id,
'type' => $type,
'weight' => $weight,
'height' => $height,
'use_time' => $use_time,
'ip' => $ip,
'ip_info' => $ip_info,
'score' => $score,
'order_id' => '0',
'person_id' => $person_id,
'person_info' => json_encode($person_info, JSON_UNESCAPED_UNICODE),
'content' => json_encode($content, JSON_UNESCAPED_UNICODE),
'items' => json_encode($items, JSON_UNESCAPED_UNICODE),
'check_items' => json_encode($check_items, JSON_UNESCAPED_UNICODE),
'check_items_array' => json_encode($check_items_array, JSON_UNESCAPED_UNICODE),
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s'),
]);
return \Yz::Return(true, '操作完成', [
'id' => $log_id
]);
}
public function getTrustedProxiesIp()
{ //获取用户真实ip
if (getenv('HTTP_CLIENT_IP') && strcasecmp(getenv('HTTP_CLIENT_IP'), 'unknown')) {
$ip = getenv('HTTP_CLIENT_IP');
} elseif (getenv('HTTP_X_FORWARDED_FOR') && strcasecmp(getenv('HTTP_X_FORWARDED_FOR'), 'unknown')) {
$ip = getenv('HTTP_X_FORWARDED_FOR');
} elseif (getenv('REMOTE_ADDR') && strcasecmp(getenv('REMOTE_ADDR'), 'unknown')) {
$ip = getenv('REMOTE_ADDR');
} elseif (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], 'unknown')) {
$ip = $_SERVER['REMOTE_ADDR'];
}
$res = preg_match('/[\d\.]{7,15}/', $ip, $matches) ? $matches[0] : '';
return $res;
}
}

@ -0,0 +1,522 @@
<?php
namespace App\Http\Controllers\API\H5;
use App\Http\Controllers\Controller;
use App\Services\ReportService;
use Illuminate\Http\Request;
use App\Http\Controllers\API\PEISApiController;
use Illuminate\Support\Facades\DB;
class ReportController extends Controller
{
public function GetReportList()
{
$openid = request('openid');
$tj_status = request('tj_status');
$hospital_id=request('hospital_id');
if (!isset($openid)) return \Yz::echoError1("openid不能为空");
if (!isset($hospital_id)) return \Yz::echoError1("hospital_id不能为空");
$user = DB::table('web_users')->where(['openid' => $openid, 'status' => 1, 'is_del' => 0])->first();
if (!$user) return \Yz::echoError1('用户不存在');
$persons = DB::table('web_user_person')->where(['user_id' => $user->id, 'is_del' => 0])->pluck('id_number')->toArray();
$report_list=[];
$peis = new PEISApiController();
foreach ($persons as $key => $id_number) {
if(strlen($id_number)==0) continue;
$data = [
'电话号码' => "",
'证件号码' => $id_number,
'体检号' => ""
];
$reports = $peis::Post('体检报告查询', $hospital_id, $data);
if (count($reports['data']) > 0) {
$reports_detail_list = $reports['data'];
foreach ($reports_detail_list as $key => $reports_detail) {
$report_list[]=$reports_detail;
}
}
}
$list=[];
foreach ($report_list as $key => $report) {
$report_list[$key]['is_read']=0;
$report_list[$key]['登记时间']= explode('T', $report_list[$key]['登记时间'])[0];
if($report['体检状态']=='报告已出' || $report['体检状态']=='总检完成'){
$cha=DB::table('report_l1_records')->where(['体检号' => $report['体检号']])->first();
if(!!$cha and $cha->is_read==1){
$report_list[$key]['is_read']=1;
}
}
if(isset($tj_status) and $tj_status!==0){
if($tj_status==1 and $report['体检状态']=='报告已出' || $report['体检状态']=='总检完成'){
$list[]= $report_list[$key];
}
if($tj_status==2 and $report['体检状态']=='报告未出'){
$list[]= $report_list[$key];
}
}else{
$list[]= $report_list[$key];
}
}
return \Yz::Return(true, "查询完成", ['list' => $list]);
// $list = DB::table('report_l1_records')->select('姓名', '性别', '登记时间', '套餐名称', '体检号', '体检状态', 'is_read')->whereIn('证件号码', $persons);
// if(isset($tj_status) and $tj_status!==0){
// if($tj_status===1){
// $tj_status='报告未出';
// $list=$list->where('体检状态', $tj_status);
//
// }
// if($tj_status===2){
// $tj_status='报告已出';
// $list=$list->where('体检状态', $tj_status);
// $list = $list->where(function ($query) use ($tj_status) {
// $query->where('体检状态', '报告已出')->orWhere('体检状态', '总检完成');
// });
// }
//
// }
// $list=$list->get();
// return \Yz::Return(true, "查询完成", ['list' => $list]);
}
public function GetReportJieLunJianYi()
{
$YiBanJianChaList = [
['name' => "身高(cm)",
'code' => "SG"],
['name' => "体重(kg)",
'code' => "TZ"],
['name' => "收缩压",
'code' => "XY(SSY)"],
['name' => "血红蛋白",
'code' => "BXBSM"],
];
$tijian_num = request('tijian_num');
$hospital_id=request('hospital_id');
if (!isset($tijian_num)) return \Yz::echoError1("tijian_num不能为空");
if (!isset($hospital_id)) return \Yz::echoError1("hospital_id不能为空");
$report = DB::table('report_l1_records as a')->where(['a.体检号' => $tijian_num])->first();
if (!$report) {
//如果本地没报告,则尝试拉取一下思信的报告
$peis = new PEISApiController();
$data = [
'电话号码' => "",
'证件号码' => "",
'体检号' => $tijian_num
];
$res = $peis::Post('体检报告查询', $hospital_id, $data);
if(count($res['data']) > 0) {
$res = $res['data'][0];
$report_res = new ReportService();
$save= $report_res->Save($res);
if($save['status']){
$report = DB::table('report_l1_records as a')->where(['a.体检号' => $tijian_num])->first();
}else{
return \Yz::Return($save['status'],$save['msg'],$save['data']);
}
}else{
return \Yz::echoError1("查询报告详情失败");
}
}
if (!!$report){
if ($report->体检状态 == '报告未出') return \Yz::echoError1("此报告暂时未出");
$items = DB::table('report_l2_items as b')->leftJoin('report_l3_base_items as c', 'b.id', '=', 'c.report_l2_id')->where(['b.reprort_l1_id' => $report->id])->get();
$v_error_items = [];
$error_items = [];
$base_items = [];
foreach ($items as $item) {
foreach ($YiBanJianChaList as $ybitem) {
if ($item->基础项目代码 == $ybitem['code']) {
$base_items[] = [
'name' => $ybitem['name'],
'value' => $item->结果值,
];
}
}
if ($item->异常标识 != null and $item->异常标识 != '') {
$error_items[] = $item;
}
}
$info = [];
$info['name'] = $report->姓名;
$info['base_date'] = $base_items;
$info['items'] = [
'all_count' => count($items),
'ipt_error_count' => count($v_error_items),//重要异常数量
'error_count' => count($error_items),//异常数量
];
$info['content'] = $report->总检建议;
DB::table('report_l1_records')->where(['id' => $report->id])->update(['is_read' => 1]);
return \Yz::Return(true, "查询完成", ['info' => $info]);
}
}
//完整报告中的列表
public function GetReportDetaiList()
{
$tijian_num = request('tijian_num');
$report = DB::table('report_l1_records as a')->where(['a.体检号' => $tijian_num])->first();
if (!$report) return \Yz::echoError1("查询报告失败");
if ($report->体检状态 == '报告未出') return \Yz::echoError1("此报告暂时未出");
$items = DB::table('report_l2_items as b')->leftJoin('report_l3_base_items as c', 'b.id', '=', 'c.report_l2_id')->where(['b.reprort_l1_id' => $report->id])->get();
$list = [];
foreach ($items as $item) {
$ShouFeiName = $item->收费项目名称;
if (!isset($list[$ShouFeiName])) {
$error_count = 0;
$list[$ShouFeiName] = ['id' => $item->report_l2_id, 'error_count' => $error_count];
}
if ($item->异常标识 != null and $item->异常标识 != '') {
$error_count++;
}
$list[$ShouFeiName] = ['id' => $item->report_l2_id, 'error_count' => $error_count];
}
return \Yz::Return(true, "查询完成", ['list' => $list]);
}
public function GetReportDetai()
{
$id = request('id');
$l2 = DB::table('report_l2_items')->where(['id' => $id])->first();
$items = DB::table('report_l3_base_items')->where(['report_l2_id' => $id])->orderBy('基础项目顺序')->get();
if ($l2->科室类型 == 'PACS') {
$suojian = [];
$zhenduan = [];
foreach ($items as $item) {
$suojian[] = empty($item->所见)?$item->结果值:$item->所见;
$jielun[] = $item->结论;
}
if (count($items) > 0) {
return \Yz::Return(true, "查询完成", ['is_pacs'=>true,'suojian' => $suojian,'jielun' => $jielun]);
} else {
return \Yz::echoError1('此项暂无内容');
}
} else {
$error_items = [];
foreach ($items as $item) {
if ($item->异常标识 != null and $item->异常标识 != '') {
$m = '';
if ($item->异常标识 == '↓') {
$m = '低';
}
if ($item->异常标识 == '↑') {
$m = '高';
}
$error_items[] = $item->基础项目名称 . $m;
}
if($item->结果类型=='数值' and $item->结果值!='' and $item->结果值!=null and $item->结果值范围!='' and $item->结果值范围 !=null){
$range = $this->convertToArray($item->结果值范围);
$item->结果值范围=$range;
$item->最大范围=[];
if(count($range)>1){
$kuadu=$range[1]-$range[0];
if($item->结果值=='未见') $item->结果值=0;
if(($item->结果值-$range[1])/$kuadu<=1){
$max=$range[1]+$kuadu;
}else{
$max=$item->结果值;
}
$item->最大范围=[0,$max];
}
}
}
if (count($items) > 0) {
return \Yz::Return(true, "查询完成", ['is_pacs'=>false,'list' => $items, 'error_items' => $error_items]);
} else {
return \Yz::echoError1('此项暂无内容');
}
}
}
function convertToArray($input) {
// 检查是否是范围表示法
if (preg_match('/^(\d*\.?\d*)-(\d*\.?\d*)$/', $input, $matches)) {
return [(float)$matches[1], (float)$matches[2]];
}
// 检查是否是小于符号
if (preg_match('/^<(\d*\.?\d*)$/', $input, $matches)) {
return [0, (float)$matches[1]];
}
// 检查是否是小于等于符号
if (preg_match('/^<=(\d*\.?\d*)$/', $input, $matches)) {
return [0, (float)$matches[1]];
}
// 如果没有匹配,返回原始输入
return $input;
}
public function contrast(Request $request)
{
$ids = $request->post('tj_numbers');
if(count($ids)<>2) return \Yz::echoError1("请选择两份报告");
if($ids[0]==$ids[1]) return \Yz::echoError1('不能选择相同的报告');
sort($ids);
$report1=DB::table('report_l1_records as a')->leftJoin('report_l2_items as b' ,'a.id','=','b.reprort_l1_id')->where('a.体检号',$ids[0])->whereIn('体检状态',['报告已出','总检完成'])->get();
$report2=DB::table('report_l1_records as a')->leftJoin('report_l2_items as b' ,'a.id','=','b.reprort_l1_id')->where('a.体检号',$ids[1])->whereIn('体检状态',['报告已出','总检完成'])->get();
if(count($report1)==0 || count($report2)==0) return \Yz::echoError1("有未出报告,无法对比");
$ids1=$ids = $report1->pluck('id')->all();
$ids2=$ids = $report2->pluck('id')->all();
$report1_jc_item=DB::table('report_l3_base_items')->whereIn('report_l2_id',$ids1)->get();
$report2_jc_item=DB::table('report_l3_base_items')->whereIn('report_l2_id',$ids2)->get();
//dd($report1_jc_item,$report2_jc_item);
$r1_datetime =$report1[0]->报告日期;
$r2_datetime =$report2[0]->报告日期;
$r1_map = [];
foreach ($report1_jc_item as $i) {
$r1_map[$i->基础项目代码] = json_decode(json_encode($i,JSON_UNESCAPED_UNICODE),true);
}
$r2_map = [];
foreach ($report2_jc_item as $i) {
$r2_map[$i->基础项目代码] = json_decode(json_encode($i,JSON_UNESCAPED_UNICODE),true);
}
$clear_type1_list = [];
$clear_type2_list = [];
$id = 1;
foreach ($r1_map as $key => $item) {
$r2_data = isset($r2_map[$key]) ? [
'date' => $r2_datetime,
'content' => $r2_map[$key]['结果值'] . $r2_map[$key]['结果值单位'],
'icon' => $r2_map[$key]['异常标识'],
'desc' => $r2_map[$key]['结果值范围'],
] : [
'date' => $r2_datetime,
'content' => '',
'icon' => '',
'desc' => ''
];
$i = [
'id' => $id,
'title' => $item['基础项目名称'],
'r1' => [
'date' => $r1_datetime,
'content' => $item['结果值'] . $item['结果值单位'],
'icon' => $item['异常标识'],
'desc' => $item['结果值范围'],
],
'r2' => $r2_data
];
if ($item['结果类型'] == '数值') {
$clear_type2_list[$key] = $i;
} else {
$clear_type1_list[$key] = $i;
}
$id = $id + 1;
}
foreach ($r2_map as $key => $item) {
$r1_data = isset($r1_map[$key]) ? [
'date' => $r1_datetime,
'content' => $r1_map[$key]['结果值'] . $r1_map[$key]['结果值单位'],
'icon' => $r1_map[$key]['异常标识'],
'desc' => $r1_map[$key]['结果值范围'],
] : [
'date' => $r1_datetime,
'content' => '',
'icon' => '',
'desc' => '',
];
$i = [
'id' => $id,
'title' => $item['基础项目名称'],
'r1' => $r1_data,
'r2' => [
'date' => $r2_datetime,
'content' => $item['结果值'] . $item['结果值单位'],
'icon' => $item['异常标识'],
'desc' => $item['结果值范围'],
]
];
if ($item['结果类型'] == '数值') {
$clear_type2_list[$key] = $i;
} else {
$clear_type1_list[$key] = $i;
}
$id = $id + 1;
}
$report_type1_content = [];
$report_type2_content = [];
foreach ($clear_type1_list as $item) {
$report_type1_content[] = $item;
}
foreach ($clear_type2_list as $item) {
$report_type2_content[] = $item;
}
return \Yz::return(true,"",[
'report_type1_content' => $report_type1_content,
'report_type2_content' => $report_type2_content,
]);
}
public function orderReportTime($res)
{
foreach ($res as $key => $re) {
$res[$key]['order_time'] = date('YmdHi', strtotime($re['登记时间']));
}
return self::myUsort($res, ['order_time'], [0]);
}
//趋势分析
public function Analysis(Request $request)
{
$id = $request->post('id');
$id_number = $request->post('id_number');
$date = $request->post('date');
$hospital = $request->post('hospital');
$analysis_type = DB::table('analysis_types')->where('id', $id)->first();
$mark = $analysis_type->mark;
$value = 0;
$unit = '';
$info['title'] = $analysis_type->name;
$info['content'] = $analysis_type->content;
$range_data = json_decode($analysis_type->range, true);
$range = $range_data['r'];
$label = $range_data['l'];
$step = $range_data['s'];
$color = ['#357e24', '#a7ea9b', '#95cde8', '#f0a93f', '#f0a93f', '#ec572c'];
$time = 0;
$range_str = '';
$data_arr = [];
$res_done_arr = [];
//查询数据库
$reports=DB::table('report_l1_records')->where(['证件号码'=>$id_number])
->whereIn('体检状态',['报告已出','总检完成'])->orderBy('报告日期','asc')->get();
$date_list = [];
$datetime = '';
foreach ($reports as $item) {
$datetime=explode('T', $item->登记时间)[0];
$jc_item=DB::table('report_l2_items as a')->leftJoin('report_l3_base_items as b','a.id','=','b.report_l2_id')->where(['a.reprort_l1_id'=>$item->id])->get();
foreach ($jc_item as $i) {
if ($i->基础项目代码 == $mark) {
if ($i->结果类型 == '数值' && !!$i->结果值范围) {
$date_list[] = $datetime;
$result = '正常';
if ($i->异常标识 == '↑') $result = '偏高';
if ($i->异常标识 == '↓') $result = '偏低';
$range_str = $i->结果值范围;
if (strtotime($datetime) > $time) {
$info['result'] = $result;
$info['value'] = $i->异常标识 . $i->结果值 . $i->结果值单位;
$value = $i->结果值;
$data_arr[] = [
'value' => $value,
'datetime' => $datetime,
];
$unit = $i->结果值单位;
$info['date'] = $datetime;
$time = strtotime($datetime);
}
$info['name'] = $i->基础项目名称;
$info['table']['name'] = $i->基础项目名称;
$info['table']['list'][] = [
'date' => $datetime,
'value' => $i->异常标识 . $i->结果值,
'assess' => $result,
];
}
}
}
}
if ($date == '') $date = $datetime;
$rc = 0;
foreach ($reports as $item) {
$datetime=explode('T', $item->登记时间);
$jc_item=DB::table('report_l2_items as a')->leftJoin('report_l3_base_items as b','a.id','=','b.report_l2_id')->where(['a.reprort_l1_id'=>$item->id])->get();
foreach ($jc_item as $i) {
if ($i->基础项目代码 == $mark) {
$result = '正常';
if ($i->异常标识 == '↑') $result = '偏高';
if ($i->异常标识 == '↓') $result = '偏低';
if ($datetime == $date) {
$info['result'] = $result;
$info['value'] = $i->异常标识 . $i->结果值 . $i->结果值单位;
$value = $i->结果值;
$unit = $i->结果值单位;
$info['date'] = $datetime;
$rc++;
}
$info['name'] = $i->基础项目名称;
$info['table']['name'] = $i->基础项目名称;
}
}
}
$chart1_option = [
'show' => true,
'range' => [],
'min' => 0,
'max' => 0,
'value' => $value,
'label' => $label,
];
$chart2_option = [
'show' => true,
'data' => $data_arr,
'min' => 0,
'max' => 0,
'unit' => $unit,
'step' => $step,
'range' => [],
];
$data_show = true;
if (!$range_str) {
$data_show = false;
$chart1_option['show'] = false;
$chart2_option['show'] = false;
} else if (strstr($range_str, '>') || strstr($range_str, '<')) {
$data_show = false;
$chart1_option['show'] = false;
$chart2_option['show'] = false;
} else {
$range_str = str_replace('~~', '-', $range_str);
$range_str = str_replace('--', '-', $range_str);
$range_str = str_replace('~', '-', $range_str);
$range_arr = explode('-', $range_str);
$min_index = array_search("min", $range);
$max_index = array_search("max", $range);
$range[$min_index] = $range_arr[0];
$range[$max_index] = $range_arr[1];
$chart1_option['min'] = $range_arr[0];
$chart1_option['max'] = $range_arr[1];
$chart2_option['range'] = $range_arr;
$chart2_option['min'] = $range[0];
$chart2_option['max'] = $range[count($range) - 1];
foreach ($range as $key => $item) {
$chart1_option['range'][] = [
'percent' => $item / ($range[count($range) - 1] - $range[0]),
'value' => $item,
'color' => $color[$key - $min_index + 1],
];
}
}
return \Yz::return(true,"查询完成",[
'date' => $date,
'date_list' => $date_list,
'show' => $data_show,
'info' => $info,
'chart1_option' => $chart1_option,
'chart2_option' => $chart2_option,
]);
}
}

@ -0,0 +1,437 @@
<?php
namespace App\Http\Controllers\API\H5;
use App\Http\Controllers\API\AspNetZhuanController;
use App\Http\Controllers\API\XCXApiController;
use App\Http\Controllers\Controller;
use App\Services\ConfigService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class UserController extends Controller
{
public function hunjianBySFZ(Request $request)
{
$sfz = $request->post('sfz');
$res = false;
if(isset($sfz)){
$dnet = new AspNetZhuanController();
$res = $dnet->GetPersonInfo([
"zjh" => $sfz,
"action" => "2",
"ghzid"=>""
]);
return \Yz::Return(true,"查询完成",['info'=>$res]);
}else{
return \Yz::echoError1('身份证不能为空');
}
}
public function hunjian(Request $request)
{
$person_id = $request->post('person_id');
$user_info = DB::table('web_user_person')->where(['id' => $person_id])->first();
$res = false;
if (!!$user_info) {
$dnet = new AspNetZhuanController();
$res = $dnet->GetPersonInfo([
"ghzid" => $user_info->ghzid,
"action" => "1"
]);
}
$id_type_map = [
'身份证' => 0,
'居民身份证' => 0,
'驾驶证' => 1,
'外国护照' => 2,
'护照' => 2,
'港澳居民来往内地通行证' => 3,
'港澳台身份证' => 3,
'港澳通行' => 3,
'外国人永久居留身份证' => 4,
'其他' => 5,
'暂未获取' => 5,
];
$person_info = [
'姓名' => ''
];
if (!!$res && count($res) != 0) {
$res = $res[0];
$id_type = $res['ID_Type_name'] ?? '居民身份证';
$id_type_show = 0;
if (isset($id_type_map[$id_type])) {
$id_type_show = $id_type_map[$id_type];
}
$address = $res['Address'] ?? '';
// $address = '海南省海口市龙华区11111111';
$address_array = [];
if (!!$address) {
$address_data_str = file_get_contents(public_path('assets/address.json'));
$address_data = json_decode($address_data_str, true);
foreach ($address_data as $ak => $av) {
if (strstr($address, $av['name']) !== false) {
$address_array[] = [
'value' => $av['code'],
'text' => $av['name']
];
foreach ($av['children'] as $aak => $aav) {
if (strstr($address, $aav['name']) !== false) {
$address_array[] = [
'value' => $aav['code'],
'text' => $aav['name']
];
foreach ($aav['children'] as $aaak => $aaav) {
if (strstr($address, $aaav['name']) !== false) {
$address_array[] = [
'value' => $aaav['code'],
'text' => $aaav['name']
];
break;
}
}
if (count($address_array) == 2) {
$address_array[] = [
'value' => $aav['children'][0]['code'],
'text' => $aav['children'][0]['name'],
];
}
break;
}
}
if (count($address_array) == 1) {
$address_array[] = [
'value' => $av['children'][0]['code'],
'text' => $av['children'][0]['name'],
];
$address_array[] = [
'value' => $av['children'][0]['children'][0]['code'],
'text' => $av['children'][0]['children'][0]['name'],
];
}
break;
}
}
}
$id_number = $res['ID_No'] ?? '';
$birthplace = '';
if ($id_type_show == 0 && mb_strlen($id_number, 'utf-8') == 18) {
$sheng = substr($id_number, 0, 2);
$shi = substr($id_number, 0, 4);
$xian = substr($id_number, 0, 6);
$address_data_str = file_get_contents(public_path('assets/address.json'));
$address_data = json_decode($address_data_str, true);
foreach ($address_data as $ak => $av) {
if ($av['code'] == $sheng) {
$birthplace = $birthplace . $av['name'];
foreach ($av['children'] as $aak => $aav) {
if ($aav['code'] == $shi) {
$birthplace = $birthplace . $aav['name'];
foreach ($aav['children'] as $aaak => $aaav) {
if ($aaav['code'] == $xian) {
$birthplace = $birthplace . $aaav['name'];
if (count($address_array) == 0) {
$address_array = [
[
'value' => $av['code'],
'text' => $av['name'],
],
[
'value' => $aav['code'],
'text' => $aav['name']
],
[
'value' => $aaav['code'],
'text' => $aaav['name']
],
];
}
break;
}
}
break;
}
}
break;
}
}
}
if (count($address_array) == 0) {
$address_array = [
[
'value' => '11',
'text' => '北京市'
],
[
'value' => '1101',
'text' => '市辖区'
],
[
'value' => '110101',
'text' => '东城区'
],
];
}
$person_info = [
'国籍' => $res['MZ'] == '外国血统' ? '外国' : '中国',
'证件类型' => $id_type_show,
'证件号' => $res['ID_No'] ?? '',
'姓名' => $res['Patname'] ?? '',
'生日' => $res['Patbdate'] ? date('Y-m-d', strtotime($res['Patbdate'])) : date('Y-m-d'),
'民族' => $res['MZ'] ?? '',
'现地址省市区' => $address_array,
'现地址' => $address,
// '详细地址省市区' => $address_array,
// '详细地址' => $address,
'户籍地址省市区' => $address_array,
'户籍地址' => $address,
'工作单位' => "",
'文化程度' => "",
'职业' => "",
'出生地' => $birthplace,
'配偶姓名' => "",
'配偶证件类型' => 0,
'配偶证件号' => "",
'血缘关系' => "无",
// '邮政编码' => "",
'手机号码' => $res['Mobile'] ?? '',
];
}
//查询日志是否曾经录入过婚检
$hunjianLog=DB::table("questions_log")->where(['personid'=>$person_id,'q_type'=>3])->orderBy('id','desc')->first();
if(!!$hunjianLog){
$person_info=json_decode($hunjianLog->content,true);
unset($person_info['详细地址省市区']);
unset($person_info['详细地址']);
unset($person_info['邮政编码']);
}
return \Yz::Return(true, '获取成功', [
'info' => $person_info
]);
}
// 获取配置更新时间
public function info(Request $request)
{
$openid = $request->post('openid');
if (!isset($openid)) return \Yz::echoError1("openid不能为空");
$user = DB::table('web_users')->where(['openid' => $openid])->first();
$userid = false;
if (!$user) {
$userid = DB::table('web_users')->insertGetId(['openid' => $openid]);
} else {
$userid = $user->id;
}
if ($userid) {
if (self::UpdatePersonList($openid)) { //调用更新就诊人方法
//查询默认就诊人
$person_list = DB::table('web_user_person')->where(['user_id' => $userid, 'is_del' => 0])->get();
$default_person = DB::table('web_user_person')->where(['user_id' => $userid, 'is_default' => 1, 'is_del' => 0])->first();
$count = count($person_list);
if ($count > 0 and !$default_person) {
DB::table('web_user_person')->where(['id' => $person_list[0]->id])->update(['is_default' => 1]);
$default_person = $person_list[0];
}
if(!$default_person) return \Yz::echoError1("获取默认体检人信息失败");
$info = [
'name' => isset($default_person->name) ? $default_person->name : null,
'sex' => isset($default_person->sex) ? $default_person->sex : null,
'phone' => isset($default_person->phone) ? $default_person->phone:null,
'id_number' => isset($default_person->id_number) ? $default_person->id_number:null,
'count' => $count,
'openid' => $openid,
'person_id' => $default_person->id,
'married' => $default_person->married
];
return \Yz::Return(true, '获取成功', [
'info' => $info
]);
}
}
}
//获取名下体检人列表
public function GetPersonList()
{
$openid = request('openid');
$user = DB::table('web_users')->where(['openid' => $openid, 'status' => 1, 'is_del' => 0])->first();
if (!$user) return \Yz::echoError1('用户不存在');
$persons = DB::table('web_user_person')->where(['user_id' => $user->id, 'is_del' => 0])->get();
return \Yz::Return(true, "查询完成", ['list' => $persons]);
}
//切换默认就诊人
public function SetDefaultPerson()
{
$openid = request('openid');
$person_id = request('person_id');
$user = DB::table('web_users')->where(['openid' => $openid, 'status' => 1, 'is_del' => 0])->first();
if (!$user) return \Yz::echoError1('用户不存在');
DB::table('web_user_person')->where(['user_id' => $user->id, 'is_del' => 0, 'is_default' => 1])->update([
'is_default' => 2
]);
$u = DB::table('web_user_person')->where(['id' => $person_id, 'user_id' => $user->id, 'is_del' => 0])->update([
'is_default' => 1
]);
if ($u) {
return \Yz::Return(true, "操作完成", []);
} else {
return \Yz::echoError1('操作失败');
}
}
//获取就诊人基本信息 积分、预存款等
public function GetPersonInfo()
{
$openid = request('openid');
$person_id = request('person_id');
$user = DB::table('web_users')->where(['openid' => $openid, 'status' => 1, 'is_del' => 0])->first();
if (!$user) return \Yz::echoError1('用户不存在');
$person = DB::table('web_user_person')->where(['user_id' => $user->id, 'is_del' => 0, 'is_default' => 1])->first();
if (!$person) return \Yz::echoError1('查询就就诊人信息出错');
//调用his接口查询用户积分和预存款
$integral = 90;
$save_money = 150;
$coupon_count = 2; //优惠券数量
$person->integral = $integral;
$person->save_money = $save_money;
$person->coupon_count = $coupon_count;
return \Yz::Return(true, "查询完成", ['person_info' => $person]);
}
public function tttt()
{
$XCX = new XCXApiController();
$data = [
'wxid' => 'oosgJj-SVIxTrm_g1p213tsSHK5g'
];
$res = $XCX::Post('就诊人列表', $data);
$ApiPersonList = $res['data'];
//dd($ApiPersonList[0]);
$XCX::XCXDecode($ApiPersonList[0]['idNumber']);
}
//更新用户列表,调用远程小程序接口
public function UpdatePersonList($openid)
{
$env = config('app.globals.Env');
if ($env == 'pro') { //如果是正式环境
$XCX = new XCXApiController();
$data = [
'wxid' => $openid
];
$res = $XCX::Post('就诊人列表', $data);
$ApiPersonList = $res['data'];
// dd($ApiPersonList);
}
if ($env == 'dev') { //如果是开发环境
$ApiPersonList = [
[
'ghzid' => 'ghz11',
'idNumber' => '15210219920524154X',
'name' => '周京京',
'phone' => '11111111111',
'sex' => '1',
'birthday' => '1989-01-01',
'patientType' => '0',
'marriage' => '1',
],
[
'ghzid' => 'ghz22',
'idNumber' => '460026199002190013',
'name' => '测试2',
'phone' => '222222222',
'sex' => '1',
'birthday' => '1990-01-01',
'patientType' => '1',
'marriage' => '1',
],
[
'ghzid' => 'ghz22555',
'idNumber' => '411329199901052356',
'name' => '信息科1',
'phone' => '222222222',
'sex' => '1',
'birthday' => '1990-01-01',
'patientType' => '1',
'marriage' => '1',
]
];
}
$user = DB::table('web_users')->where(['openid' => $openid, 'status' => 1, 'is_del' => 0])->first();
if (!$user) return \Yz::echoError1('用户不存在');
//库里存在的用户ghzid数组
$db_person_ghzids = DB::table('web_user_person')->where(['user_id' => $user->id, 'is_del' => 0])->pluck('ghzid')->toArray();
//接口返回的用户ghzids数组
$api_person_ghzids = [];
foreach ($ApiPersonList as $apiperson) {
$api_person_ghzids[] = $apiperson['ghzid'];
}
// 取交集
$intersection = array_intersect($db_person_ghzids, $api_person_ghzids);
// 仅存在于 数据库里 中的ghzid
$onlyInDb = array_diff($db_person_ghzids, $api_person_ghzids);
// 仅存在于 api接口 中的ghzid
$onlyInApi = array_diff($api_person_ghzids, $db_person_ghzids);
$success_count = 0;
foreach ($ApiPersonList as $apiperson) {
$marriage = 0;
if ($apiperson['marriage'] == '未婚') {
$marriage = 2;
}
if ($apiperson['marriage'] == '已婚') {
$marriage = 1;
}
$personInfo = [
'ghzid' => $apiperson['ghzid'],
'id_number' => $env == 'dev' ? $apiperson['idNumber'] : $XCX::XCXDecode($apiperson['idNumber']),
'name' => $apiperson['name'],
'birthday' => $apiperson['birthday'],
'sex' => $apiperson['sex'],
'phone' => $env == 'dev' ? $apiperson['phone'] : $XCX::XCXDecode($apiperson['phone']),
'married' => $marriage,
'user_id' => $user->id,
'patient_type' => $apiperson['patientType'],
'updated_at' => date('Y-m-d H:i:s')
];
if (in_array($apiperson['ghzid'], $intersection)) { //双方都有的,更新
$u = DB::table('web_user_person')->where(['user_id' => $user->id, 'ghzid' => $apiperson['ghzid']])->update($personInfo);
if ($u) $success_count += $u;
}
if (in_array($apiperson['ghzid'], $onlyInApi)) { //小程序新增的 添加
$i = DB::table('web_user_person')->insert($personInfo);
if ($i) $success_count++;
}
}
if (count($onlyInDb) > 0) { //小程序不存在的用户 ,数据进行删除
$d = DB::table('web_user_person')->where(['user_id' => $user->id])->whereIn('ghzid', $onlyInDb)->update([
'is_del' => 1
]);
if ($d) $success_count++;
}
//设置默认体检人
// $default=DB::table('web_user_person')->where(['user_id' => $user->id,'is_del'=>0,'is_default'=>1])->get();
// $p_list=DB::table('web_user_person')->where(['user_id' => $user->id,'is_del'=>0])->get();
// if(count($p_list)>0 and count($default)===0){
// DB::table('web_user_person')->where(['id'=>$p_list[0]->id])->update(['is_default'=>1]);
// }
return true;
}
}

@ -0,0 +1,138 @@
<?php
namespace App\Http\Controllers\API\Internal;
use App\Http\Controllers\API\PEISApiController;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class OrderController extends Controller
{
//到检
public function TJCheck()
{
$password = request('password');
$serve_id = request('serve_id');
$exam_id = request('exam_id');
if(!isset($exam_id) or empty($exam_id)) return \Yz::echoError1("体检号不能为空");
if ($password !== 'YRtA1rx1iWgbpYKX') return \Yz::echoError1("校验密码失败");
if (isset($serve_id) and !empty($serve_id) and $serve_id <> '') { //到检通知
$orderInfo = DB::table('orders')->where('appointment_number', $serve_id)->orderBy('id', 'desc')->first();
if (!$orderInfo){
return $this->CreateOrder($exam_id);
}else{
if (!!$exam_id) {
if ($orderInfo->status == 1) return \Yz::echoError1("订单未付款");
if ($orderInfo->status == 3) return \Yz::echoError1("订单已取消");
if ($orderInfo->status == 4 || $orderInfo->check_status == 2) return \Yz::echoError1("人员已经到检");
if ($orderInfo->status == 5) return \Yz::echoError1("订单已退款");
// $peis = new PEISApiController();
// $data = [
// "电话号码" => $orderInfo->phone,
// "证件号码" => $orderInfo->id_number,
// ];
// $info = $peis::Post('分诊查询体检号', $orderInfo->hospital_id,$data);
DB::table('orders')->where('id', $orderInfo->id)->update([
'status' => 4,
// 'tj_number'=>$info['data'][0]['体检号'],
'tj_number' => $exam_id,
'check_status' => 2,
'check_time' => date('Y-m-d H:i:s')
]);
return \Yz::Return(true, "", ['id' => $orderInfo->id]);
} else {
return \Yz::echoError1("体检号不能为空");
}
}
} else { //体检直接登记用户信息没经过h5登记。根据体检号查询信息入库
return $this->CreateOrder($exam_id);
}
}
//根据体检号拉取数据进行存储
public function CreateOrder($exam_id)
{
if (isset($exam_id)) {
$peis = new PEISApiController();
$data = [
'电话号码' => "",
'证件号码' => "",
'体检号' => $exam_id,
'包含内部信息' => true
];
$reports = $peis::Post('体检报告查询', 1, $data);
if (isset($reports['data'][0]['收费项目列表'])) {
$data = $reports['data'][0];
$items=[];
foreach ($data['收费项目列表'] as $it) {
$items[]=[
'id' => $it['收费项目Id'],
'name' => $it['收费项目名称'],
'price' => '',
];
}
$buyInfo=[
'combo'=>[
'id'=>0,
'name'=>'',
'price'=>''
],
'items'=>$items,
'group'=>[
'id'=>'',
]
];
$sex = 0;
if ($data['性别'] == '男') $sex = 1;
if ($data['性别'] == '女') $sex = 2;
$dataInfo = [
'hospital_id'=>1,
'title' => $data['套餐名称'],
'type' => $data['单位名称'] == '个人' ? 1 : 2,
'source' => '体检推送',
'name' => $data['姓名'],
'id_number' => $data['证件号码'],
'person_id'=>0,
'buy_info' => json_encode($buyInfo, JSON_UNESCAPED_UNICODE),
'status' => 4,
'plan_number' => $data['分诊信息'],
'appointment_date' => explode('T', $data['登记时间'])[0],
'tj_number' => $exam_id,
'phone' => $data['电话号码'],
'sex' => $sex,
'birthday' => explode('T', $data['出生日期'])[0],
'check_status' => 2,
'check_time' => $data['登记时间'],
];
$insert=DB::table('orders')->insert($dataInfo);
if($insert){
return \Yz::Return(true, "创建成功", ['id' => $insert]);
}else{
return \Yz::echoError1("创建失败");
}
} else {
return \Yz::echoError1("根据体检号查询用户信息出错,结果非预期");
}
} else {
return \Yz::echoError1("体检号不能为空");
}
}
public function GetH5Order()
{
$appointment_number = request('appointment_number');//思信预约完成后的id
if (!isset($appointment_number) || empty($appointment_number)) return \Yz::echoError1('预约id 不能为空');
$order_info = DB::table('orders')->where(['appointment_number' => $appointment_number, 'status' => 2, 'check_status' => 1])->first();
if (!!$order_info) {
$order_info->buy_info = json_decode($order_info->buy_info, true);
$order_info->erxian_appointment_info = json_decode($order_info->erxian_appointment_info, true);
} else {
return \Yz::echoError1('未找到有效订单');
}
return \Yz::Return(true, '获取成功', [
'info' => $order_info
]);
}
}

@ -0,0 +1,62 @@
<?php
namespace App\Http\Controllers\API\Internal;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class PlanController extends Controller
{
//给自助机用接口
//获取可用号源列表,
public function PlanList()
{
$hospital_id =request('hospital');
$date=request('date');
$is_vip=request('is_vip');
$checkup_type_id=(string)request('checkup_type_id');//体检类型表对应id
if(!isset($checkup_type_id)) return \Yz::echoError1("体检类型不能为空");
$currentDateTime = now();
$list=DB::table('plans')
->where('date',$date)->whereIn('status',[1])
->whereRaw('CONCAT(date, " ", time) >?', [$currentDateTime])
->whereRaw('JSON_CONTAINS(checkup_type_id, ?, "$")',[$checkup_type_id])
->where(['hospital_id'=>$hospital_id,'type'=>1,'is_del'=>0])
->where('is_vip','=',$is_vip);
$list=$list->get();
return \Yz::Return(true,"查询完成",['list'=>$list]);
}
//给自助机用接口
//占用号源
public function UsePlan(){
$id =request('id');
$plan=DB::table('plans')->where('id',$id)->first();
if(!$plan) return \Yz::echoError1("该号源不存在");
if($plan->status<>1) return \Yz::echoError1("该号源已被占用,请重新选择");
$u=DB::table('plans')->where(['id'=>$id,'status'=>1,'is_del'=>0])->update(['status'=>2]);
if($u){
return \Yz::Return(true,'占用成功',['id'=>$id]);
}else{
return \Yz::echoError1("操作失败");
}
}
public function CancelUsePlan()
{
$id =request('id');
$plan=DB::table('plans')->where('id',$id)->first();
if(!$plan) return \Yz::echoError1("该号源不存在");
if($plan->status<>2) return \Yz::echoError1("该号源未被占用,无需撤销");
$u=DB::table('plans')->where(['id'=>$id])->update(['status'=>1]);
if($u){
return \Yz::Return(true,'撤销占用成功',['id'=>$id]);
}else{
return \Yz::echoError1("操作失败");
}
}
}

@ -0,0 +1,79 @@
<?php
namespace App\Http\Controllers\API\Internal;
use App\Http\Controllers\Controller;
use App\Services\ComboItemGroupService;
use App\Services\ReportService;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class SiXinPushController extends Controller
{
public static $request;
public function PushInfo(Request $request)
{
$key = $request->query('key');
$code = $request->query('code');//推送类型 "UpdateInfo".套餐、项目、分组 信息变更 "report".报告推送 "pdf".推送pdf
$content = $request->post();
$codeMark = [
'updateInfo' => '套餐项目分组',
'report' => '报告',
'pdf' => 'pdf文件'
];
if (!array_key_exists($code, $codeMark)) return \Yz::echoError1("code不正确");
if (isset($key) && $key == "xFgq6WzWFNYL6QwKKLtxqYn2NfQnNu3a") {
self::RequestLog('', $content, $code, $codeMark[$code]);
//如果推送的是报告
if ($code == 'report') {
$report = new ReportService();
$report_save= $report->Save($content);
return \Yz::Return($report_save['status'],$report_save['msg'],$report_save['data']);
}
//如果推送的是套餐、项目、分组
if ($code == 'updateInfo') {
$ComboItemGroup=new ComboItemGroupService();
return $ComboItemGroup->Save($content);
}
return \Yz::Return(true, "接收完成", $code);
} else {
return \Yz::echoError1("密钥错误");
}
}
public static function RequestLog($url, $post_data, $code, $mark)
{
self::CheckTableName();
$post_data = json_encode($post_data, JSON_UNESCAPED_UNICODE);
self::$request->code = $code;
self::$request->mark = $mark;
self::$request->post_data = $post_data == '[]' ? '{}' : $post_data;
self::$request->request_url = $url;
self::$request->save();
}
public static function CheckTableName()
{
$table_name = 'zz_sixin_push_log_' . date('ym');
$table_count = DB::select('select count(1) as c from information_schema.TABLES where table_schema = ? and table_name = ?', [env('DB_DATABASE'), $table_name])[0];
if ($table_count->c === 0) {
Schema::create($table_name, function (Blueprint $table) {
$table->id();
$table->string('code', 50)->index();
$table->string('mark', 50)->index();
$table->longText('post_data');
$table->text('response_data')->nullable();
$table->string('request_url', 2000);
$table->timestamps();
});
}
self::$request = new \App\Models\PEISLog();
self::$request->setTable($table_name);
}
}

@ -0,0 +1,22 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use App\Services\LogService;
use Illuminate\Http\Request;
class LogController extends Controller
{
public function GetList(){
$page =request('page');
$pagesize =request('pageSize');
$searchInfo =request('searchInfo');
$s= new LogService();
return $s->GetList(['page'=>$page,'pagesize'=>$pagesize,'searchInfo'=>$searchInfo]);
}
public function GetLogTableName(){
$s= new LogService();
return $s->GetLogTableName();
}
}

@ -0,0 +1,207 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Exceptions\HttpResponseException;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
class PEISApiController extends Controller
{
public static $request;
public static function Api($url_code, $code)
{
//正式
$env=config('app.globals.Env');
if($env=='pro') { //如果是正式环境
//思信测试环境H5正式环境
$url = 'http://220.174.210.111:8899';
$api['套餐详情查询'] = "{$url}/PEISCommon/QueryComboDetail?key=YmMxOGI2MDUxZmFh";
$api['自选项目查询'] = "{$url}/PEISCommon/QueryGroups?key=YmMxOGI2MDUxZmFh";
$api['套餐查询'] = "{$url}/PEISCommon/QueryCombos?key=YmMxOGI2MDUxZmFh";
$api['套餐项目检查'] = "{$url}/PEISCommon/CheckComboAndGroup?key=YmMxOGI2MDUxZmFh";
$api['个检预约'] = "{$url}/PEISCommon/PersonAppointment?key=YmMxOGI2MDUxZmFh";
$api['个检预约查询'] = "{$url}/PEISCommon/QueryPersonAppointment?key=YmMxOGI2MDUxZmFh";
$api['个检预约取消'] = "{$url}/PEISCommon/CancelPersonAppointment?key=YmMxOGI2MDUxZmFh";
$api['团检登记查询'] = "{$url}/PEISCommon/QueryUnitAppointmentReg?key=YmMxOGI2MDUxZmFh";
$api['团检预约'] = "{$url}/PEISCommon/UnitAppointment?key=YmMxOGI2MDUxZmFh";
$api['团检预约查询'] = "{$url}/PEISCommon/QueryUnitAppointment?key=YmMxOGI2MDUxZmFh";
$api['团检预约取消'] = "{$url}/PEISCommon/CancelUnitAppointment?key=YmMxOGI2MDUxZmFh";
$api['体检报告查询'] = "{$url}/PEISCommon/QueryExamReport?key=YmMxOGI2MDUxZmFh";
$api['预约时段修改'] = "{$url}/PEISCommon/ModifyAppointmentDTRange?key=YmMxOGI2MDUxZmFh";
$api['修改用户预约时间'] = "{$url}/ExtAPI/SetAppointmentMoment?key=YmMxOGI2MDUxZmFh&{$code}";
$api['分诊查询体检号'] = "{$url}/PEISCommon/QueryEventNo?key=YmMxOGI2MDUxZmFh";
$api['单位分组批次查询'] = "{$url}/PEISCommon/QueryBatchAndGroup?key=YmMxOGI2MDUxZmFh";
$api['报告时间计算'] = "{$url}/Home/CalcReportDays?eventNos={$code}";
$api['弃检接口'] = "{$url}/Home/AbandonCheck";
$api['检后签到'] = "{$url}/Home/PostExamSignIn?eventNo={$code}";
}
if($env=='dev') { //如果是测试环境
$url = 'https://dqgatjzx-wx.sixinyun.com';
$api['套餐详情查询'] = "{$url}/PEISCommon/QueryComboDetail/{$code}";
$api['自选项目查询'] = "{$url}/PEISCommon/QueryGroups/{$code}";
$api['套餐查询'] = "{$url}/PEISCommon/QueryCombos/{$code}";
$api['套餐项目检查'] = "{$url}/PEISCommon/CheckComboAndGroup/{$code}";
$api['个检预约'] = "{$url}/PEISCommon/PersonAppointment/{$code}";
$api['个检预约查询'] = "{$url}/PEISCommon/QueryPersonAppointment/{$code}";
$api['个检预约取消'] = "{$url}/PEISCommon/CancelPersonAppointment/{$code}";
$api['团检登记查询'] = "{$url}/PEISCommon/QueryUnitAppointmentReg/{$code}";
$api['团检预约'] = "{$url}/PEISCommon/UnitAppointment/{$code}";
$api['团检预约查询'] = "{$url}/PEISCommon/QueryUnitAppointment/{$code}";
$api['团检预约取消'] = "{$url}/PEISCommon/CancelUnitAppointment/{$code}";
$api['体检报告查询'] = "{$url}/PEISCommon/QueryExamReport/{$code}";
$api['预约时段修改'] = "{$url}/PEISCommon/ModifyAppointmentDTRange/{$code}";
$api['修改用户预约时间'] = "http://220.174.210.111:8888/ExtAPI/SetAppointmentMoment?key=YmMxOGI2MDUxZmFh&{$code}";
$api['分诊查询体检号'] = "{$url}/PEISCommon/QueryEventNo/{$code}";
$api['单位分组批次查询'] = "{$url}/PEISCommon/QueryBatchAndGroup/{$code}";
$api['报告时间计算'] = "{$url}/Home/CalcReportDays?eventNos={$code}";
$api['弃检接口'] = "{$url}/Home/AbandonCheck/{$code}";
$api['检后签到'] = "{$url}/Home/PostExamSignIn?eventNo={$code}";
}
return $api["{$url_code}"] ?? $url_code;
}
public static function Post($url_code, $hospital_id, $data, $print = false)
{
$hospital = DB::table('hospitals')->where(['id' => $hospital_id, 'status' => 1, 'is_del' => 0])->first();
if (!$hospital) return \Yz::echoError1('医院不存在或不可用');
$code = $hospital->code;
$url = self::Api($url_code, $code);
self::RequestLog($url, $data, $code, $url_code);
$data_string = json_encode($data, JSON_UNESCAPED_UNICODE);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json; charset=utf-8',
'Content-Length: ' . strlen($data_string)
]);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
$res_string = curl_exec($ch);
curl_close($ch);
$str_len = mb_strlen($res_string, 'utf-8');
$str_size = $str_len / 1024;
$save_res = $res_string;
if ($str_size > 10) $save_res = '{"data":"Row size too large"}';
self::$request->response_data = $save_res;
self::$request->save();
if (!json_decode($res_string, true)) {
throw new HttpResponseException( \Yz::echoError1("体检系统提示:".$res_string));
}
$res = json_decode($res_string, true);
if ($res['ResultCode'] != 0){
throw new HttpResponseException( \Yz::echoError1("体检系统提示:". $res['ResultContent']));
}
return [
'code' => $res['ResultCode'],
'message' => $res['ResultContent'],
'data' => $res['Records']
];
}
public static function Post2($url_code,$url, $hospital_id, $data)
{
$hospital = DB::table('hospitals')->where(['id' => $hospital_id, 'status' => 1, 'is_del' => 0])->first();
if (!$hospital) return \Yz::echoError1('医院不存在或不可用');
$code = $hospital->code;
self::RequestLog($url, $data, $code, $url_code);
$data_string = json_encode($data, JSON_UNESCAPED_UNICODE);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json; charset=utf-8',
'Content-Length: ' . strlen($data_string)
]);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
$res_string = curl_exec($ch);
curl_close($ch);
$str_len = mb_strlen($res_string, 'utf-8');
$str_size = $str_len / 1024;
$save_res = $res_string;
if ($str_size > 10) $save_res = '{"data":"Row size too large"}';
self::$request->response_data = $save_res;
self::$request->save();
return $res_string;
}
public static function Get($url,$code,$mark)
{
self::RequestLog($url, [], $code,$mark);
$response = Http::get($url);
if ($response->successful()) {
$res = $response->json();
self::$request->response_data = json_encode($res, JSON_UNESCAPED_UNICODE);
self::$request->save();
return $res;
} else {
$status = $response->status();
// 获取响应体作为字符串
$body = $response->body();
self::$request->response_data = $body;
self::$request->save();
throw new HttpResponseException(\Yz::echoError1("调用".$mark."接口失败:" . $status . "body:" . $body));
}
}
public static function RequestLog($url, $post_data, $code, $mark)
{
self::CheckTableName();
foreach ($post_data as $key => $post_datum) {
$str_len = mb_strlen(json_encode($post_datum, JSON_UNESCAPED_UNICODE), 'utf-8');
$str_size = $str_len / 1024;
if ($str_size > 10) {
$post_data["$key"] = 'Row size too large';
}
}
$post_data = json_encode($post_data, JSON_UNESCAPED_UNICODE);
self::$request->code = $code;
self::$request->mark = $mark;
self::$request->post_data = $post_data == '[]' ? '{}' : $post_data;
self::$request->request_url = $url;
self::$request->save();
}
public static function CheckTableName()
{
$table_name = 'zz_peis_log_' . date('ym');
$table_count = DB::select('select count(1) as c from information_schema.TABLES where table_schema = ? and table_name = ?', [env('DB_DATABASE'), $table_name])[0];
if ($table_count->c === 0) {
Schema::create($table_name, function (Blueprint $table) {
$table->id();
$table->string('code', 50)->index();
$table->string('mark', 50)->index();
$table->text('post_data');
$table->text('response_data')->nullable();
$table->string('request_url', 2000);
$table->timestamps();
});
}
self::$request = new \App\Models\PEISLog();
self::$request->setTable($table_name);
}
}

@ -0,0 +1,54 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class SendMsgCodeController extends Controller
{
//创建验证码
public function SendMsgCode(Request $request)
{
$mobile = request('mobile');
//查找相同手机号1分钟内是否发送过
$code = DB::table('send_code')->where('mobile', $mobile)->where('created_at', '>=', date('Y-m-d H:i:s', time() - 60))->first();
if ($code) {
return \Yz::echoError1("操作太频繁,请稍后再试");
}
$code = rand(100000, 999999);
//获取当前时间5分钟后的日期时间
$end_time = date('Y-m-d H:i:s', time() + 300);
$i=DB::table('send_code')->insert([
'mobile' => $mobile,
'code' => $code,
'created_at' => date('Y-m-d H:i:s'),
'end_time' => $end_time
]);
if ($i) {
$aspnet=new AspNetZhuanController();
$aspnet::SendYanZhengMaCode(1,$mobile,$code);
return \Yz::Return(true,"发送成功",[]);
} else {
return \Yz::echoError1("发送失败");
}
}
//验证验证码
public function CheckMsgCode(){
$mobile = request('mobile');
$code = request('code');
$u = DB::table('send_code')
->where('mobile', $mobile)
->where('code', $code)
->where('end_time', '>=', date('Y-m-d H:i:s'))
->where(['status' => 1])
->update(['status' => 2]);
if($u){
return \Yz::Return(true,"验证成功",['data'=>$code]);
}else{
return \Yz::echoError1("验证码无效");
}
}
}

@ -0,0 +1,23 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Services\TokenService;
class TokenController extends Controller
{
public function TokenRefresh(Request $request ) //token 过期调用此方法
{
$token=request()->header('Authorization');;
$service=app()->make(TokenService::class);
$s=$service->RefreshToken(['token'=>$token]);
// // var_dump($m);
if(!$s['status']){
$s['status']=false;
}
return $s;
}
}

@ -0,0 +1,30 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use App\Services\Admin\YeWu\HealthCheckupService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
class UpLoadController extends Controller
{
public function UpFile(){
$file=request('file');
if ($file->isValid()) {
// $s=app()->make(HealthCheckupService::class);
// $save=$s->SaveFile(['file'=>$file]);
$date = date("Ymd");
$save = $file->store('public/'.$date);
return \Yz::Return(true,'上传成功',Storage::url($save));
}else{
return \Yz::echoError1('获取文件失败');
}
}
}

@ -0,0 +1,174 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use WeChatPay\Builder;
use WeChatPay\Crypto\AesGcm;
use WeChatPay\Crypto\Rsa;
use WeChatPay\Formatter;
use WeChatPay\Util\PemUtil;
class WeChatPayController extends Controller
{
public static $mp_instance = false;
public static $mp_config = false;
public function callback($input, $header, $apiv3Key, $pem)
{
$inWechatpaySignature = $header['wechatpay-signature'][0];
$inWechatpayTimestamp = $header['wechatpay-timestamp'][0];
$inWechatpaySerial = $header['wechatpay-serial'][0];
$inWechatpayNonce = $header['wechatpay-nonce'][0];
$inBody = $input;
$platformPublicKeyInstance = Rsa::from($pem, Rsa::KEY_TYPE_PUBLIC);
$timeOffsetStatus = 300 >= abs(Formatter::timestamp() - (int)$inWechatpayTimestamp);
// $verifiedStatus = Rsa::verify(
// Formatter::joinedByLineFeed($inWechatpayTimestamp, $inWechatpayNonce, $inBody),
// $inWechatpaySignature,
// $platformPublicKeyInstance
// );
// if ($timeOffsetStatus && $verifiedStatus) {
if ($timeOffsetStatus) {
$inBodyArray = (array)json_decode($inBody, true);
['resource' => [
'ciphertext' => $ciphertext,
'nonce' => $nonce,
'associated_data' => $aad
]] = $inBodyArray;
$inBodyResource = AesGcm::decrypt($ciphertext, $apiv3Key, $nonce, $aad);
return (array)json_decode($inBodyResource, true);
} else {
return false;
}
}
public function builder($config)
{
self::$mp_config = $config;
$merchantPrivateKeyFilePath = 'file://' . self::$mp_config['pem_path'];
$platformCertificateFilePath = 'file://' . self::$mp_config['cer_path'];
$merchantId = self::$mp_config['mchid'];
$merchantPrivateKeyInstance = Rsa::from($merchantPrivateKeyFilePath, Rsa::KEY_TYPE_PRIVATE);
self::$mp_config['pem_key'] = $merchantPrivateKeyInstance;
$merchantCertificateSerial = self::$mp_config['cer_num'];
$platformPublicKeyInstance = Rsa::from($platformCertificateFilePath, Rsa::KEY_TYPE_PUBLIC);
$platformCertificateSerial = self::$mp_config['v3'];
self::$mp_instance = Builder::factory([
'mchid' => $merchantId,
'serial' => $merchantCertificateSerial,
'privateKey' => $merchantPrivateKeyInstance,
'certs' => [
$platformCertificateSerial => $platformPublicKeyInstance,
],
]);
}
public function refund($config)
{
$res = false;
try {
$resp = self::$mp_instance
->v3->refund->domestic->refunds
->post([
'json' => [
'transaction_id' => $config['transaction_id'],
'out_refund_no' => $config['out_refund_no'],
'amount' => [
'refund' => $config['total'],
'total' => $config['total'],
'currency' => 'CNY',
],
],
]);
$res = json_decode($resp->getBody(), true);
} catch (\Exception $e) {
if ($e instanceof \GuzzleHttp\Exception\RequestException && $e->hasResponse()) {
$r = $e->getResponse();
$res = json_decode($r->getBody(), true);
}
}
return $res;
}
public function create($config)
{
$res = false;
try {
$post_data = [
'appid' => self::$mp_config['appid'],
'mchid' => self::$mp_config['mchid'],
'description' => $config['description'],
'out_trade_no' => $config['out_trade_no'],
'notify_url' => $config['notify_url'],
'amount' => [
'total' => $config['total'],
],
'payer' => [
'openid' => $config['openid']
]
];
$resp = self::$mp_instance
->v3->pay->transactions->jsapi
->post([
'json' => $post_data,
]);
$res = json_decode($resp->getBody(), true);
} catch (\Exception $e) {
if ($e instanceof \GuzzleHttp\Exception\RequestException && $e->hasResponse()) {
$r = $e->getResponse();
$res = json_decode($r->getBody(), true);
}
}
$params = [
'appId' => self::$mp_config['appid'],
'timeStamp' => (string)time(),
'nonceStr' => self::nonce(),
'package' => 'prepay_id=' . $res['prepay_id'],
];
$params += ['paySign' => Rsa::sign(
Formatter::joinedByLineFeed(...array_values($params)),
self::$mp_config['pem_key']
), 'signType' => 'RSA'];
return [
'appid' => $params['appId'],
'timestamp' => $params['timeStamp'],
'nonce_str' => $params['nonceStr'],
'package' => $params['package'],
'pay_sign' => $params['paySign'],
'sign_type' => $params['signType'],
];
}
public function check($out_trade_no)
{
$res = false;
try {
$resp = self::$mp_instance
->v3->pay->transactions->outTradeNo->_out_trade_no_
->get([
'query' => ['mchid' => self::$mp_config['mchid']],
'out_trade_no' => (string)$out_trade_no,
]);
$res = json_decode($resp->getBody(), true);
} catch (\Exception $e) {
if ($e instanceof \GuzzleHttp\Exception\RequestException && $e->hasResponse()) {
$r = $e->getResponse();
$res = json_decode($r->getBody(), true);
}
}
return $res;
}
public static function nonce($l = 16)
{
$charts = "ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz0123456789";
$max = strlen($charts) - 1;
$noncestr = "";
for ($i = 0; $i < $l; $i++) {
$noncestr .= $charts[rand(0, $max)];
}
return $noncestr;
}
}

@ -0,0 +1,294 @@
<?php
namespace App\Http\Controllers\API\Web;
use App\Http\Controllers\API\H5\PersonController;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class ComboController extends Controller
{
//医生端网页打开页面获取套餐列表
public function GetList(){
$hospital = request('hospital');
$sex=request('sex');
$combo_sort = request('combo_sort');
$combo_type = request('combo_type');
$combo_crowd = request('combo_crowd');
$combo_price =request('combo_price');
$combo_item = request('combo_item');
$hospital = DB::table('hospitals')->select('id', 'name', 'address', 'latitude', 'longitude')->where(['id' => $hospital])->first();
$canshu = [];
$canshu[]=$sex;
$sql = '';
if (isset($combo_price)) {
$price_list = [
"1" => [0, 299],
"2" => [300, 999],
"3" => [1000, 1499],
"4" => [1500, 2999],
"5" => [3000, 999999],
];
$sql = " and (a.price>=? and a.price<=?) ";
$canshu[] = $price_list[$combo_price][0];
$canshu[] = $price_list[$combo_price][1];
}
if (isset($combo_type)) {
$sql = $sql . " and a.type_id=? ";
$canshu[] = $combo_type;
}
if (isset($combo_crowd)) {
$sql = $sql . " and a.crowd_id=? ";
$canshu[] = $combo_crowd;
}
if (isset($combo_sort)) {
if ($combo_sort == 1) {
$sql = $sql . " ";
}
if ($combo_sort == 2) {
$sql = $sql . " ";
}
if ($combo_sort == 3) {
$sql = $sql . " order by a.price";
}
if ($combo_sort == 4) {
$sql = $sql . " order by a.price desc";
}
}
$combos = DB::select("select * from combos as a LEFT JOIN (
select combo_id as c_id,count(*) as count from orders where status in(2,4) group by combo_id
) as b on a.combo_id=b.c_id where a.status=1 and a.sex=?" . $sql, $canshu);
foreach ($combos as $key => $combo) {
$combo->count=$combo->count?$combo->count:0;
$tags = json_decode($combo->tags, true);
$combo->tags2 = json_decode($combo->tags2, true);
foreach ($tags as $k => $tag) {
$tags[$k] = ['text' => $tag,
'text_color' => '#47ABD8',
'color' => '#EBF5FC'
];
}
$combo->tag = $tags;
$combo->tag[] = [
'text' => $combo->item_count . '个项目',
'text_color' => '#34C292',
'color' => '#E9F8F3',
];
}
$hospital_info = $hospital;
return \Yz::Return(true, '获取成功', [
'list' => $combos,
'hospital' => $hospital_info
]);
}
//医生端网页打开页面获取购买详情内容(详情页信息)
public function BuyInfo()
{
$hospital_id = request('hospital');
$combo_id = request('combo_id'); //购买的套餐id
$item_ids = request('item_ids'); //自选项目ids
$group_id = request('group_id'); //团检登记id
if (!isset($hospital_id)) return \Yz::echoError1("医院id不能为空");
$hospital = DB::table('hospitals')->where(['id' => 1, 'status' => 1, 'is_del' => 0])->first();
$combo_info = false;//套餐信息
$pay_item_count = 0;//需自费项目个数
$all_original_price = 0;
$true_price = 0;
$nmr_list=[];
if (isset($combo_id) and $combo_id != 0) {
// $combo=DB::table('combos')->where(['hospital_id'=>$hospital_id,'combo_id'=>$combo_id,'status'=>1])->first();
$combo = DB::select("select a.*,b.*,c.name as crowd_name from combos as a LEFT JOIN (
select combo_id as c_id,count(*) as sale_count from orders where status in(2,4) group by combo_id
) as b on a.combo_id=b.c_id left join combo_crowd as c on a.crowd_id=c.id where a.combo_id=? and a.status=1 ", [$combo_id]);
if (!$combo) return \Yz::echoError1("套餐不存在");
$combo = $combo[0];
$combo_info['hospital_name'] = $hospital->name;
$combo_info['combo_name'] = $combo->name;
$combo_info['crowd_name'] = $combo->crowd_name;
$combo_info['img'] = $combo->cover;
$combo_info['sale_count'] = $combo->sale_count==null?0:$combo->sale_count;
$tags = json_decode($combo->tags, true);
$combo->tags2 = json_decode($combo->tags2, true);
foreach ($tags as $k => $tag) {
$tags[$k] = ['text' => $tag,
'text_color' => '#47ABD8',
'color' => '#EBF5FC'
];
}
$combo->tag = $tags;
$combo->tag[] = [
'text' => $combo->item_count . '个项目',
'text_color' => '#34C292',
'color' => '#E9F8F3',
];
$combo_info['tags'] = $combo->tag;
$combo_info['tags2'] = $combo->tags2;
$combo_info['price'] = $combo->price;
$combo_info['original_price'] = $combo->original_price;
$all_original_price += $combo_info['original_price'];
$combo_items = json_decode($combo->items, true);
$groupedData = [];
foreach ($combo_items as $item) {
$keshiName = $item['keshi_name'];
if (!isset($groupedData[$keshiName])) {
$groupedData[$keshiName] = [];
}
$groupedData[$keshiName][] = $item;
}
foreach ($groupedData as $keshiName => $children) {
$combo_info['items'][] = [
'keshi_name' => $keshiName,
'children' => $children
];
}
$pay_item_count += $combo->item_count;
$true_price += $combo_info['price'];
//如果有影像科则存储在nmr_list
$comboItem=DB::table('combo_items')->where(['combo_id' => $combo_id, 'status' => 1,'keshi_name'=>'影像科'])->get();
if(count($comboItem)>0){
foreach ($comboItem as $item){
$nmr_list[]=[
'item_id' => $item->item_id,
'name' => $item->name,
];
}
}
}
$items_info = false;//自选项目信息
if (isset($item_ids) and !empty($item_ids)) {
$price = 0;
$items_original_price = 0;
$items = DB::table('items')->whereIn('item_id', $item_ids)->where(['status' => 1])->get();
$groupedData = [];
foreach ($items as $item) {
// $price=$price+$item->price;
$price = bcadd($price, $item->price, 2);
// $all_original_price+=$item->original_price;
$all_original_price = bcadd($all_original_price, $item->original_price, 2);
// $items_original_price+=$item->original_price;
$items_original_price = bcadd($items_original_price, $item->original_price, 2);
$keshiName = $item->keshi_name;
if (!isset($groupedData[$keshiName])) {
$groupedData[$keshiName] = [];
}
$groupedData[$keshiName][] = ['id'=>$item->item_id,'desc' => $item->jianjie, 'name' => $item->name,'price'=>$item->price];
//如果有影像科则存储在nmr_list字段
if($item->keshi_name=='影像科'){
$nmr_list[]=[
'item_id' => $item->item_id,
'name' => $item->name,
];
}
}
$items_info['price'] = $price;
$items_info['original_price'] = $items_original_price;
foreach ($groupedData as $keshiName => $children) {
$items_info['items'][] = [
'keshi_name' => $keshiName,
'children' => $children
];
}
$pay_item_count += count($items);
$true_price += $items_info['price'];
}
//调用his接口查询用户积分和预存款计算可以抵扣的金额
$integral_money = 90;//积分抵扣金额
$save_money = 150;//预存款抵扣金额
$coupon_money = 50;//优惠券抵扣金额
//用户真实支付价格,应减去抵扣(二期实现)
$group_info = false;
$lose_price=0;
if (!!$group_id) {
$P = new PersonController();
$data = [
'电话号码' => null,
'证件号码' => null,
'预约Id' => $group_id
];
$group_info = $P->group_info($hospital_id, $data);
if(count($group_info)==0) return \Yz::echoError1("获取团检登记信息失败");
//如果是团检统收限额大于0并且没有自带项目则判断剩余金额
if($group_info[0]['tongshou_xiane']>0 and count($group_info[0]['items'])==0){
$lose_price=$group_info[0]['tongshou_xiane']- $true_price;
if($lose_price<0) $lose_price=0;
}
$true_price = $true_price + $group_info[0]['sixi_zong_ji_jin_e'];
$true_price = ($true_price - $group_info[0]['tongshou_xiane']) > 0 ? $true_price - $group_info[0]['tongshou_xiane'] : 0;
$all_items = DB::table('items')->where(['status' => 1])->get();
$item_new = [];
foreach ($group_info[0]['items'] as $item) {
$item['keshi_name'] = '其他';
$item['desc'] = '';
foreach ($all_items as $it) {
if ($it->item_id == $item['id']) {
$item['keshi_name'] = $it->keshi_name;
$item['desc'] = $it->jianjie;
if($it->keshi_name=='影像科'){
$nmr_list[]=[
'item_id' => $it->item_id,
'name' => $it->name,
];
}
break;
}
}
$item_new[] = $item;
}
$groupedData = [];
foreach ($item_new as $item) {
$keshiName = $item['keshi_name'];
if (!isset($groupedData[$keshiName])) {
$groupedData[$keshiName] = [];
}
$groupedData[$keshiName][] = ['desc' => $item['desc'], 'name' => $item['name'], 'id' => $item['id'], 'keshi_name' => $item['keshi_name']];
}
$group_info[0]['items'] = [];//清空原来的item
foreach ($groupedData as $keshiName => $children) {
$group_info[0]['items'][] = [
'keshi_name' => $keshiName,
'children' => $children
];
}
}
$data = [
'group_info' => $group_info,
'combo_info' => $combo_info,
'items_info' => $items_info,
'integral_money' => number_format($integral_money, 2, '.', ''),
'save_money' =>number_format($save_money, 2, '.', ''),
'coupon_money' => number_format($coupon_money, 2, '.', ''),
'true_price' =>number_format($true_price, 2, '.', ''),//需要用户支付的金的
'original_price' =>number_format($all_original_price, 2, '.', '') ,//总原价
'pay_item_count' => $pay_item_count,//需要付费的项目数量
'lose_price'=>number_format($lose_price, 2, '.', ''),//剩余的不用就会浪费的金额
'nmr_list' => $nmr_list//核磁项目列表
];
return \Yz::Return(true, "查询成功", $data);
}
}

@ -0,0 +1,73 @@
<?php
namespace App\Http\Controllers\API\Web;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class ItemController extends Controller
{
//医生端网页打开页面获取项目列表
public function GetList()
{
$hospital = request('hospital');
$sex=request('sex');
//查询所有可以自选的项目
$items=DB::table('items')->where(['is_choose'=>1,'status'=>1])->get();
$search= request('search');
$list = [];
$group_arr = [];
$group_list = [];
foreach ($items as $item) {
if($item->sex <> $sex and $item->sex<>0){
continue;
}
$push_type = false;
if ($search == '') {
$push_type = true;
} else {
$check_name = $item->name;
if (strpos($check_name, $search) !== false) {
$push_type = true;
}
$check_py = $item->pinyin;
if (strpos($check_py, mb_strtoupper($search)) !== false) {
$push_type = true;
}
$check_group = $item->keshi_name;
if (strpos($check_group, $search) !== false) {
$push_type = true;
}
}
if ($push_type) {
if (!in_array($item->keshi_id, $group_arr)) {
$group_list["科室{$item->keshi_id}"] = [
'id' => $item->keshi_id,
'title' => $item->keshi_name,
'head_img'=>'/storage/20240822/banner1.png',
'children' => [],
];
$group_arr[] = $item->keshi_id;
}
$group_list["科室{$item->keshi_id}"]['children'][] = [
'id' => $item->item_id,
'title' => $item->name,
'price' =>$item->price,
'original_price'=>$item->original_price,
'pinyin' => $item->pinyin,
'desc'=>$item->jianjie,
'sex'=>$item->sex,
'can_qian_hou'=>$item->can_qian_hou
];
}
}
return \Yz::Return(true,"查询成功",['list'=>$group_list]);
}
}

@ -0,0 +1,494 @@
<?php
namespace App\Http\Controllers\API\Web;
use App\Http\Controllers\API\H5\PersonController;
use App\Http\Controllers\API\H5\PlanController;
use App\Http\Controllers\API\PEISApiController;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class OrderController extends Controller
{
//创建订单
public function Create()
{
$hospital_id = request('hospital');
$person_id = request('person_id');
$combo_id = request('combo_id');
$type = request('type');//1个检2团检
$group_id = request('group_id');//团检id
$item_ids = request('item_ids');//自选item的ids
$plan_id = request('plan_id');//号源id
$doctor = request('doctor');//预约的医生名字
$appdoctor = request('appdoctor');//协助预约的医生名字
$person= request('person'); //sex,birthday,married,name,id_number,phone
$married_array=["未婚","已婚","丧偶","离婚","其他"];
if(isset($person['married'])){
$key= array_search($person['married'], $married_array);
if ($key !== false) {
$person['married']=$key;
} else {
$person['married']=4;
}
}
if (!isset($hospital_id)) return \Yz::echoError1('医院id不能为空');
if (!isset($type)) return \Yz::echoError1('type体检类型不能为空');
if ($type != 1 && $type != 2) {
return \Yz::echoError1('type参数体检类型错误');
}
if (!isset($plan_id)) return \Yz::echoError1('号源id不能为空');
if ($type == 2 and !isset($group_id)) return \Yz::echoError1('团检group_id不能为空');
if ($type == 1 and isset($group_id)) return \Yz::echoError1('体检类型:个检 与group_id冲突');
$title = "自选项目";
$price = 0;
$true_price = 0;//订单真实支付金额
$buy_info = [
'combo' => [
'id' => 0,
'name' => $title,
'price' => 0,
],
'items' => [],
'group' => [
'id' => '',
],
'nmr_list'=>[]
];
//如果是套餐
$TJ_Leixing_id=1;//存储用体检类型
$checkup_type_id = false; //体检类型id
if (isset($combo_id) and $combo_id <> 0) {
$combo_info = DB::table('combos')->where(['combo_id' => $combo_id, 'status' => 1])->first();
if (!$combo_info) return \Yz::echoError1("套餐不存在");
if (!isset($combo_info->checkup_type_id)) return \Yz::echoError1("套餐未关联体检类型");
$checkup_type_id = $combo_info->checkup_type_id;
$TJ_Leixing_id=$checkup_type_id;
$price += $combo_info->price;
$title = $combo_info->name;
$buy_info['combo'] = [
'id' => $combo_info->combo_id,
'name' => $combo_info->name,
'price' => $combo_info->price,
];
//如果有影像科则存储在nmr_list字段
$comboItem=DB::table('combo_items')->where(['combo_id' => $combo_id, 'status' => 1,'keshi_name'=>'影像科'])->get();
if(count($comboItem)>0){
foreach ($comboItem as $item){
$buy_info['nmr_list'][]=[
'item_id' => $item->item_id,
'name' => $item->name,
];
}
}
}
//如果有自选项目
$items_list = [];
if (count($item_ids) != 0) {
$items_list = DB::table('items')->whereIn('item_id', $item_ids)->where(['status' => 1])->get();
$existingIds = [];
foreach ($items_list as $item) {
$price += $item->price;
$existingIds[] = $item->item_id;
$buy_info['items'][] = [
'id' => $item->item_id,
'name' => $item->name,
'price' => $item->price
];
//如果有影像科则存储在nmr_list字段
if($item->keshi_name=='影像科'){
$buy_info['nmr_list'][]=[
'item_id' => $item->item_id,
'name' => $item->name,
];
}
}
$missingIds = array_diff($item_ids, $existingIds);
if (count($missingIds) > 0) return \Yz::echoError1("部分自选项目不可用Id:" . implode(', ', $missingIds));
}
$true_price = $price;
//如果是团检
$group_info = false;
if ($type == 2) {
$P = new PersonController();
$data = [
'电话号码' => null,
'证件号码' => null,
'预约Id' => $group_id
];
$group_info = $P->group_info($hospital_id, $data);
$group_info = $group_info[0];
$buy_info['group'] = [
'id' => $group_id,
'combo_name' => $group_info['combo_name'],
'combo_id' => $group_info['combo_id'],
'group_name' => $group_info['group_name'],
'items' => $group_info['items'],
'group_id' => $group_info['group_id'],
];
$TJ_Leixing_id=$group_info['checkup_type_id'];
$title = "单位团检" . $group_info['combo_name'];
$price = $price + $group_info['sixi_zong_ji_jin_e'];
$need_pay = ($price - $group_info['tongshou_xiane']) > 0 ? $price - $group_info['tongshou_xiane'] : 0;
//团检订单金额为减去统收后的金的
$price = $need_pay;
$true_price = $need_pay;
//如果有影像科则存储在nmr_list字段
$all_items = DB::table('items')->where(['status' => 1,'keshi_name'=>'影像科'])->get();
foreach ($group_info['items'] as $item) {
foreach ($all_items as $it) {
if ($it->item_id == $item['id']) {
$buy_info['nmr_list'][]=[
'item_id' => $item->item_id,
'name' => $item->name,
];
}
}
}
}
//调用思信接口判断各个项目是否可用
$check_items = [];
foreach ($item_ids as $item_id) {
$check_items[] = ['Id' => $item_id];
}
if ((isset($combo_id) and $combo_id <> 0) || count($check_items) != 0) {
$item_check = self::item_check($hospital_id, [
'人员信息列表' => [[
"序号" => 0,
"性别" => $person['sex'] == 1 ? '男' : '女',
"年龄" => floor((time() - strtotime($person['birthday'])) / 86400 / 360),
"婚姻状态" => $person['married']== 1 ? '已婚' : '未婚',
]],
'套餐Id' => $combo_id == 0 ? null : $combo_id,
'可选项目信息' => $check_items,
]);
if (count($item_check['data']) != 1) {
return \Yz::echoError1("体检系统提示:" . $item_check['message']);
}
}
//检查号源是否可用
$plan = new PlanController();
$plan_check = $plan->CheckPlan($plan_id, $hospital_id, $type, $person['sex'], $price, $checkup_type_id);
if ($plan_check['status'] === false) return \Yz::echoError1($plan_check['msg']);
$plan = $plan_check['plan'];
//如果是团检 判断号源在 团检登记人的有效时间范围内
$plan_datetime = $plan->date . ' ' . $plan->time;
if (!!$group_info) {
if (!($plan_datetime > $group_info['start_time'] . ' 00:00:00' and $plan_datetime < $group_info['end_time'] . ' 23:59:59')) {
return \Yz::echoError1("预约日期不在单位有效时间范围内,请重新选择");
}
}
//构建订单号
$order_num = $this->generateOrderNumber();
$data = [
'title' => $title,
'type' => $type,
'source' => 'web',
'web_user_id' =>0,
'checkup_type_id'=>$TJ_Leixing_id,
'person_id' => 0,
'name' => $person['name'],
'id_number' => $person['id_number'],
'buy_info' => json_encode($buy_info, JSON_UNESCAPED_UNICODE),
'price' => $price,
'true_price' => $true_price,
'order_number' => $order_num,
'status' => 1,
'appointment_date' => $plan->date,
'appointment_time' => $plan->time,
'plan_id' => $plan->id,
'plan_number' => $plan->plan_number,
'combo_id' => $combo_id,
'hospital_id' => $hospital_id,
'doctor' => $doctor,
'appdoctor'=>$appdoctor,
'phone' => $person['phone'],
'sex' => $person['sex'],
'birthday' => $person['birthday'],
'married' => $person['married'],
];
DB::beginTransaction();
$insert = DB::table('orders')->insertGetId($data);
$up_plan = DB::table('plans')->where(['id' => $plan->id, 'status' => 1])->update([
'status' => 2
]);
if ($insert and $up_plan) {
DB::commit();
$action=false;
if($true_price===0){
//如果是免费的,直接去预约
$yuyue= self::Finish($order_num);
if($yuyue['status']===true){
return \Yz::return(true, "操作成功", ['action' => $action,'orderid'=>$insert]);
}else{
return \Yz::echoError1($yuyue['msg']);
}
}
if($true_price>0){
//如果大于0则提示前端去支付
$action="pay";
}
return \Yz::return(true, "操作成功", ['action' => $action,'orderid'=>$insert]);
} else {
DB::rollBack();
return \Yz::echoError1('操作失败');
}
}
//客服预约,只占用号源
public function CreateYuYueOrder()
{
$hospital_id = request('hospital');
$person_id = request('person_id');
$combo_id = request('combo_id');
$type = request('type');//1个检2团检
$group_id = request('group_id');//团检id
$item_ids = request('item_ids');//自选item的ids
$plan_id = request('plan_id');//号源id
$doctor = request('doctor');//预约的医生名字
$appdoctor = request('appdoctor');//协助预约的医生名字
$person= request('person'); //sex,birthday,married,name,id_number,phone
$married_array=["未婚","已婚","丧偶","离婚","其他"];
if(isset($person['married'])){
$key= array_search($person['married'], $married_array);
if ($key !== false) {
$person['married']=$key;
} else {
$person['married']=4;
}
}
if (!isset($hospital_id)) return \Yz::echoError1('医院id不能为空');
if (!isset($type)) return \Yz::echoError1('type体检类型不能为空');
if ($type != 1 && $type != 2) {
return \Yz::echoError1('type参数体检类型错误');
}
if (!isset($plan_id)) return \Yz::echoError1('号源id不能为空');
if ($type == 2 and !isset($group_id)) return \Yz::echoError1('团检group_id不能为空');
if ($type == 1 and isset($group_id)) return \Yz::echoError1('体检类型:个检 与group_id冲突');
$title = "自选项目";
$price = 0;
$true_price = 0;//订单真实支付金额
$buy_info = [
'combo' => [
'id' => 0,
'name' => $title,
'price' => 0,
],
'items' => [],
'group' => [
'id' => '',
],
'nmr_list'=>[]
];
//如果是套餐
$TJ_Leixing_id=1;//存储用体检类型
$checkup_type_id = false; //体检类型id
if (isset($combo_id) and $combo_id <> 0) {
$combo_info = DB::table('combos')->where(['combo_id' => $combo_id, 'status' => 1])->first();
if (!$combo_info) return \Yz::echoError1("套餐不存在");
if (!isset($combo_info->checkup_type_id)) return \Yz::echoError1("套餐未关联体检类型");
$checkup_type_id = $combo_info->checkup_type_id;
$TJ_Leixing_id=$checkup_type_id;
$price += $combo_info->price;
$title = $combo_info->name;
$buy_info['combo'] = [
'id' => $combo_info->combo_id,
'name' => $combo_info->name,
'price' => $combo_info->price,
];
//如果有影像科则存储在nmr_list字段
$comboItem=DB::table('combo_items')->where(['combo_id' => $combo_id, 'status' => 1,'keshi_name'=>'影像科'])->get();
if(count($comboItem)>0){
foreach ($comboItem as $item){
$buy_info['nmr_list'][]=[
'item_id' => $item->item_id,
'name' => $item->name,
];
}
}
}
//如果有自选项目
$items_list = [];
if (count($item_ids) != 0) {
$items_list = DB::table('items')->whereIn('item_id', $item_ids)->where(['status' => 1])->get();
$existingIds = [];
foreach ($items_list as $item) {
$price += $item->price;
$existingIds[] = $item->item_id;
$buy_info['items'][] = [
'id' => $item->item_id,
'name' => $item->name,
'price' => $item->price
];
//如果有影像科则存储在nmr_list字段
if($item->keshi_name=='影像科'){
$buy_info['nmr_list'][]=[
'item_id' => $item->item_id,
'name' => $item->name,
];
}
}
$missingIds = array_diff($item_ids, $existingIds);
if (count($missingIds) > 0) return \Yz::echoError1("部分自选项目不可用Id:" . implode(', ', $missingIds));
}
$true_price = $price;
//如果是团检
$group_info = false;
if ($type == 2) {
$P = new PersonController();
$data = [
'电话号码' => null,
'证件号码' => null,
'预约Id' => $group_id
];
$group_info = $P->group_info($hospital_id, $data);
$group_info = $group_info[0];
$buy_info['group'] = [
'id' => $group_id,
'combo_name' => $group_info['combo_name'],
'combo_id' => $group_info['combo_id'],
'group_name' => $group_info['group_name'],
'items' => $group_info['items'],
'group_id' => $group_info['group_id'],
];
$TJ_Leixing_id=$group_info['checkup_type_id'];
$title = "单位团检" . $group_info['combo_name'];
$price = $price + $group_info['sixi_zong_ji_jin_e'];
$need_pay = ($price - $group_info['tongshou_xiane']) > 0 ? $price - $group_info['tongshou_xiane'] : 0;
//团检订单金额为减去统收后的金的
$price = $need_pay;
$true_price = $need_pay;
//如果有影像科则存储在nmr_list字段
$all_items = DB::table('items')->where(['status' => 1,'keshi_name'=>'影像科'])->get();
foreach ($group_info['items'] as $item) {
foreach ($all_items as $it) {
if ($it->item_id == $item['id']) {
$buy_info['nmr_list'][]=[
'item_id' => $item->item_id,
'name' => $item->name,
];
}
}
}
}
//调用思信接口判断各个项目是否可用
$check_items = [];
foreach ($item_ids as $item_id) {
$check_items[] = ['Id' => $item_id];
}
if ((isset($combo_id) and $combo_id <> 0) || count($check_items) != 0) {
$item_check = self::item_check($hospital_id, [
'人员信息列表' => [[
"序号" => 0,
"性别" => $person['sex'] == 1 ? '男' : '女',
"年龄" => floor((time() - strtotime($person['birthday'])) / 86400 / 360),
"婚姻状态" => $person['married']== 1 ? '已婚' : '未婚',
]],
'套餐Id' => $combo_id == 0 ? null : $combo_id,
'可选项目信息' => $check_items,
]);
if (count($item_check['data']) != 1) {
return \Yz::echoError1("体检系统提示:" . $item_check['message']);
}
}
//检查号源是否可用
$plan = new PlanController();
$plan_check = $plan->CheckPlan($plan_id, $hospital_id, $type, $person['sex'], $price, $checkup_type_id);
if ($plan_check['status'] === false) return \Yz::echoError1($plan_check['msg']);
$plan = $plan_check['plan'];
//如果是团检 判断号源在 团检登记人的有效时间范围内
$plan_datetime = $plan->date . ' ' . $plan->time;
if (!!$group_info) {
if (!($plan_datetime > $group_info['start_time'] . ' 00:00:00' and $plan_datetime < $group_info['end_time'] . ' 23:59:59')) {
return \Yz::echoError1("预约日期不在单位有效时间范围内,请重新选择");
}
}
//构建订单号
$order_num = $this->generateOrderNumber();
$data = [
'title' => $title,
'type' => $type,
'source' => 'web',
'web_user_id' =>0,
'checkup_type_id'=>$TJ_Leixing_id,
'person_id' => 0,
'name' => $person['name'],
'id_number' => $person['id_number'],
'buy_info' => json_encode($buy_info, JSON_UNESCAPED_UNICODE),
'price' => $price,
'true_price' => $true_price,
'order_number' => $order_num,
'status' => 1,
'appointment_date' => $plan->date,
'appointment_time' => $plan->time,
'plan_id' => $plan->id,
'plan_number' => $plan->plan_number,
'combo_id' => $combo_id,
'hospital_id' => $hospital_id,
'doctor' => $doctor,
'appdoctor'=>$appdoctor,
'phone' => $person['phone'],
'sex' => $person['sex'],
'birthday' => $person['birthday'],
'married' => $person['married'],
];
DB::beginTransaction();
$insert = DB::table('orders_yuyue')->insertGetId($data);
$up_plan = DB::table('plans')->where(['id' => $plan->id, 'status' => 1])->update([
'status' => 2
]);
if ($insert and $up_plan) {
DB::commit();
return \Yz::return(true, "操作成功", ['orderid'=>$insert]);
} else {
DB::rollBack();
return \Yz::echoError1('操作失败');
}
}
public function item_check($hospital, $data)
{
$peis = new PEISApiController();
$check = $peis::Post('套餐项目检查', $hospital, $data);
return $check;
}
public function generateOrderNumber()
{
// 获取当前时间的时间戳(精确到毫秒)
$timestamp = round(microtime(true) * 1000);
// 生成一个随机数(可以根据需要调整长度)
$randomPart = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 6);
// 拼接时间戳和随机部分
$orderNumber = date("YmdHis", $timestamp / 1000) . substr($timestamp % 1000, -3) . $randomPart;
return $orderNumber;
}
}

@ -0,0 +1,182 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Http\Exceptions\HttpResponseException;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\Storage;
class XCXApiController extends Controller
{
public static $request;
// public static $appid = "13a159e438a742dd932c9bddbfaa41e5";//appid测试
public static $appid = "bce44f3abdd24f169193ab6f70326457";//appid 正式
public static $signType = "OPENAPI-SHA256-RSA2048";//签名认证类型
// public static $baseUrl = "https://xdfe-api.hnxdfe.com/hisminitest";
public static $baseUrl = "https://xdfe-api.hnxdfe.com/hisminipro";
public static function Api($url_code)
{
$api['就诊人列表'] = "/jeecg-boot/hospital/openapi/archive/list";
$api['订单查询'] = "/jeecg-boot/hospital/openapi/order/query";
$api['订单退款'] = "/jeecg-boot/hospital/openapi/order/refund";
return $api["{$url_code}"] ?? $url_code;
}
public static function Post($url_code, $data)
{
$url_address = self::Api($url_code);
self::RequestLog(self::$baseUrl . $url_address, $data, $url_code, '小程序接口');
$timestamp = time();
$nonce = md5(uniqid(rand(), true));
$base64Signature = self::Sign($url_address, $data, $nonce, $timestamp);
$response = Http::withHeaders([
'Authorization' => self::BuildAuthorization($nonce, $timestamp, $base64Signature)
])->post(self::$baseUrl . $url_address, $data);
// dd(self::BuildAuthorization($nonce, $timestamp, $base64Signature));
if ($response->successful()) {
// 处理成功的响应
$res_string = json_encode($response->json(), JSON_UNESCAPED_UNICODE);
// dd($res_string);
$str_len = mb_strlen($res_string, 'utf-8');
$str_size = $str_len / 1024;
$save_res = $res_string;
if ($str_size > 10) $save_res = '{"data":"Row size too large"}';
self::$request->response_data = $save_res;
self::$request->save();
$res = json_decode($res_string, true);
if (!$res['success']) {
throw new HttpResponseException(\Yz::echoError1("小程序接口提示:" . $res['message']));
}
return [
'code' => $res['code'],
'message' => $res['message'],
'data' => $res['result']
];
} else {
// 处理失败的响应
self::$request->response_data = "请求小程序接口失败";
self::$request->save();
throw new HttpResponseException(\Yz::echoError1("请求小程序接口失败"));
}
}
public static function RequestLog($url, $post_data, $mark, $code = 0)
{
self::CheckTableName();
foreach ($post_data as $key => $post_datum) {
$str_len = mb_strlen(json_encode($post_datum, JSON_UNESCAPED_UNICODE), 'utf-8');
$str_size = $str_len / 1024;
if ($str_size > 10) {
$post_data["$key"] = 'Row size too large';
}
}
$post_data = json_encode($post_data, JSON_UNESCAPED_UNICODE);
self::$request->code = $code;
self::$request->mark = $mark;
self::$request->post_data = $post_data == '[]' ? '{}' : $post_data;
self::$request->request_url = $url;
self::$request->save();
}
public static function CheckTableName()
{
$table_name = 'zz_peis_log_' . date('ym');
$table_count = DB::select('select count(1) as c from information_schema.TABLES where table_schema = ? and table_name = ?', [env('DB_DATABASE'), $table_name])[0];
if ($table_count->c === 0) {
Schema::create($table_name, function (Blueprint $table) {
$table->id();
$table->string('code', 50)->index();
$table->string('mark', 50)->index();
$table->text('post_data');
$table->text('response_data')->nullable();
$table->string('request_url', 2000);
$table->timestamps();
});
}
self::$request = new \App\Models\PEISLog();
self::$request->setTable($table_name);
}
//构造请求报文主体 首先将请求报文的参数名按照字典序进行排序,然后用&拼接各个参数
public static function buildSortedQueryString($params)
{
// 1. 按照参数名排序
ksort($params);
// 2. 拼接参数名和参数值
$queryString = http_build_query($params, '', '&', PHP_QUERY_RFC3986);
return $queryString;
}
//计算签名和 Authorization
public static function Sign($url, $data, $nonce, $timestamp, $is_urlencode = false)
{
$body = self::buildSortedQueryString($data);
$method = 'POST';
// $method = 'POST';
// $url = '/jeecg-boot/hospital/openapi/order/create';
// $timestamp = "1727231032";
// $nonce = 'km4W4cjDqwNee1Tw';
// $body = 'amount=1&appid=13a159e438a742dd932c9bddbfaa41e5&ghzid=c5ce8410ba854d879a0abf689923ca0d&order_desc=单位团检&orderid=20240915183440999WMp2yu&sub_org_code=6';
//dd($body);
$private_key = Storage::get('keys/private_key.pem');
$SignStr = $method . "\n" .
$url . "\n" .
$timestamp . "\n" .
$nonce . "\n" .
urldecode($body) . "\n";
// 使用私钥进行 RSA 签名
openssl_sign($SignStr, $signature, $private_key, OPENSSL_ALGO_SHA256);
// 对签名结果进行 Base64 编码
$base64Signature = base64_encode($signature);
if ($is_urlencode) {
$base64Signature = urlencode($base64Signature);
}
// dd($SignStr,$base64Signature);
return $base64Signature;
}
//构建Authorization
public static function BuildAuthorization($nonce, $currentTimestamp, $base64Signature)
{
$signInfo = "appid=\"" . self::$appid . "\",nonce=\"" . $nonce . "\",timestamp=\"" . $currentTimestamp . "\",signature=\"" . $base64Signature . "\"";
//dd($signInfo);
return self::$signType . ' ' . $signInfo;
}
//解密
public static function XCXDecode($str)
{
$private_key = Storage::get('keys/private_key.pem');
$str = base64_decode($str);
// dd($str);
if (openssl_private_decrypt($str, $decryptedData, $private_key, OPENSSL_PKCS1_OAEP_PADDING)) {
return $decryptedData;
} else {
throw new HttpResponseException(\Yz::echoError1("解密数据失败"));
}
}
}

@ -0,0 +1,13 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}

@ -0,0 +1,287 @@
<?php
namespace App\Http\Controllers\H5;
use App\Http\Controllers\API\PEISApiController;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Http\Controllers\API\H5\FenzhenController as fzc;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use PhpOffice\PhpSpreadsheet\IOFactory;
class FenzhenController extends Controller
{
public function check_in_action(Request $request)
{
$id_number = $request->post('id_number');
$id = $request->post('id');
if (!$id_number) return \Yz::echoError('请输入身份证');
$queue = [];
$fzc = new fzc();
$res = $fzc->fz('change', [
'id_number' => $id_number,
'id' => $id,
]);
if ($res['code'] == 200) {
$queue_info = $res['data']['queue'];
if (!!$queue_info) {
$queue = [[
'id' => $queue_info['id'],
'name' => $queue_info['name'],
'clinic' => $queue_info['clinic_name'],
'item' => $queue_info['item_name'],
]];
}
}
return \Yz::Return(true, '操作完成', [
'queue' => $queue
]);
}
public function check_in(Request $request)
{
$id_number = $request->get('id_number');
if (!$id_number) {
$id_number = '';
}
$queue = [];
if (!!$id_number) {
$fzc = new fzc();
$res = $fzc->fz('search', [
'id_number' => $id_number
]);
if ($res['code'] == 200) {
$queue_info = $res['data']['queue'];
if (!!$queue_info) {
$queue = [[
'id' => $queue_info['id'],
'name' => $queue_info['name'],
'clinic' => $queue_info['clinic_name'],
'item' => $queue_info['item_name'],
]];
}
}
}
return view('fenzhen', [
'id_number' => $id_number,
'queue' => $queue
]);
}
public function export(){
$fzc = new fzc();
$date=request('date');
$res = $fzc->fz('export', [
'date' => $date
]);
$table_list=$res['data']['table1'];
$clinic_list=$res['data']['table2'];
$table_list3=$res['data']['table3'];
// dd(json_encode($res['data'],JSON_UNESCAPED_UNICODE));
$template_path = Storage::path('public/excel/check_time.xlsx');
$spreadsheet = IOFactory::load($template_path);
$worksheet = $spreadsheet->getActiveSheet();
$styleArray = [
'borders' => [
'allBorders' => [
'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
'color' => ['argb' => 'FF000000'],
],
],
];
$row = 3;
$col = [
'A' => 'date',
'B' => 'name',
'C' => 'number',
'D' => 'phone',
'E' => 'group_name',
'F' => 'clinic',
'G' => 'doctor',
'H' => 'queue',
'I' => 'calling',
'J' => 'done',
'K' => 'clinic_check_time',
'L' => 'true_check_time',
'M' => 'timeout_check_time',
'N' => 'clinic_wait_time',
'O' => 'true_wait_time',
'P' => 'timeout_wait_time',
'Q' => 'clinic_all_time',
'R' => 'true_all_time',
'S' => 'timeout_all_time',
];
foreach ($table_list as $table_item) {
foreach ($col as $index => $key) {
$worksheet->setCellValueExplicit($index . $row, $table_item[$key], \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
}
$row++;
}
$worksheet->getStyle('A3:S' . ($row - 1))->applyFromArray($styleArray);
$row = 3;
$col = [
'U' => 'group_name',
'V' => 'clinic',
'W' => 'doctor',
'X' => 'check',
'Y' => 'check_out',
'Z' => 'wait',
'AA' => 'wait_out',
];
foreach ($clinic_list as $clinic_item) {
foreach ($col as $index => $key) {
$worksheet->setCellValueExplicit($index . $row, $clinic_item[$key], \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
}
$row++;
}
$worksheet->getStyle('U3:AA' . ($row - 1))->applyFromArray($styleArray);
$row = 3;
$col = [
'AC' => 'date',
'AD' => 'name',
'AE' => 'number',
'AF' => 'phone',
'AG' => 'combo',
'AH' => 'clinic_time',
'AI' => 'used_time',
'AJ' => 'timeout',
];
//汇总信息
$usercount=count($table_list3);
$biaozhun_timecount=0;
$shiji_timecount=0;
$chaoshi_timecount=0;
$weichaoshi_count=0;
$tj_numbers=[];
foreach ($table_list3 as $table_list3_i) {
$tj_numbers[]=$table_list3_i['uuid'];
$biaozhun_timecount+=$table_list3_i['clinic_time'];
$shiji_timecount+=$table_list3_i['used_time'];
$chaoshi_timecount+=$table_list3_i['timeout'];
if($table_list3_i['timeout']<=0){
$weichaoshi_count++;
}
$peis = new PEISApiController();
$data = [
'电话号码' => "",
'证件号码' => "",
'体检号' => $table_list3_i['uuid'],
'包含内部信息' => true
];
$reports = $peis::Post('体检报告查询', 1, $data);
if(isset($reports['data'][0]['套餐名称'])){
$table_list3_i['combo']=$reports['data'][0]['套餐名称'];
}else{
$table_list3_i['combo']='';
}
foreach ($col as $index => $key) {
$worksheet->setCellValueExplicit($index . $row, $table_list3_i[$key], \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
}
$row++;
}
$zhushilv=0;
if($usercount>0){
$zhushilv=$weichaoshi_count/$usercount;
}
$worksheet->setCellValueExplicit('AC' . $row, '汇总', \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
$worksheet->setCellValueExplicit('AD' . $row, '客户总数', \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
$worksheet->setCellValueExplicit('AE' . $row, $usercount, \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
$worksheet->setCellValueExplicit('AG' . $row, '总用时:', \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
$worksheet->setCellValueExplicit('AH' . $row, $biaozhun_timecount, \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
$worksheet->setCellValueExplicit('AI' . $row, $shiji_timecount, \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
$worksheet->setCellValueExplicit('AJ' . $row, $chaoshi_timecount, \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
$worksheet->setCellValueExplicit('AD' . ($row+1), '未超时总数', \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
$worksheet->setCellValueExplicit('AE' . ($row+1), $weichaoshi_count, \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
$worksheet->setCellValueExplicit('AD' . ($row+2), "体检准时率", \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
$worksheet->setCellValueExplicit('AE' . ($row+2),$zhushilv , \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
$worksheet->getStyle('AC3:AJ' . ($row +2))->applyFromArray($styleArray);
//准时到检率
$tj_numbers=implode(",", $tj_numbers);
$peis = new PEISApiController();
$wait=$peis::Get($peis::Api('报告时间计算',$tj_numbers),'460107000001',"报告时间计算");
$jianhou_sign_count=0;
$zhunshi_count=0;
//dd($wait);
if(isset($wait['Data'])){
$jianhou_sign_count=count($wait['Data']);
}
foreach ($table_list3 as $key=> $fz_value) {
foreach ($wait['Data'] as $index => $sx_value) {
if($fz_value['uuid']==$sx_value['体检号']){
if($date.' '.$fz_value['end_time']>$sx_value['检后签到时间']){
$zhunshi_count++;
}
}
}
}
$daojianlv=0;
if($jianhou_sign_count>0){
$daojianlv=$zhunshi_count/$jianhou_sign_count;
}
$worksheet->setCellValueExplicit('AL' . 3,$date , \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
$worksheet->setCellValueExplicit('AM' . 3,$zhunshi_count , \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
$worksheet->setCellValueExplicit('AN' . 3,$jianhou_sign_count , \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
$worksheet->setCellValueExplicit('AO' . 3,round($daojianlv, 2) , \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
$worksheet->getStyle('AL3:AO' . 3)->applyFromArray($styleArray);
//预约率
$yyl_yuyue_count=0;//预约人数
$yyl_tj_count=0;//体检总人数
$yuyuelv=0;
$yuyueList=DB::table('orders')->where(['appointment_date'=>$date])->whereIn('status',[2,4])->whereNotNull(['appointment_number'])->get();
$yyl_yuyue_count=count($yuyueList);
$yyl_tj_count=$usercount;
if($yyl_tj_count>0){
$yuyuelv=$yyl_yuyue_count/$yyl_tj_count;
}
$worksheet->setCellValueExplicit('AL' . 7,$date , \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
$worksheet->setCellValueExplicit('AM' . 7,$yyl_yuyue_count , \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
$worksheet->setCellValueExplicit('AN' . 7,$yyl_tj_count , \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
$worksheet->setCellValueExplicit('AO' . 7,round($yuyuelv, 2) , \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
$worksheet->getStyle('AL7:AO' . 7)->applyFromArray($styleArray);
//预约准时率
$yyzsl_ren_count=0;//预约准时到达人数
$yyzsl_zong_count=0;//预约总人数
$yyzsl_zong_count=$yyl_yuyue_count;
foreach ($yuyueList as $key=> $yy_value) {
if($yy_value->appointment_date.' '.$yy_value->appointment_time > $yy_value->check_time){
$yyzsl_ren_count++;
}
}
$zhunshilv=0;
if($yyzsl_zong_count>0){
$zhunshilv=$yyzsl_ren_count/$yyzsl_zong_count;
}
$worksheet->setCellValueExplicit('AL' . 11,$date , \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
$worksheet->setCellValueExplicit('AM' . 11,$yyzsl_ren_count , \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
$worksheet->setCellValueExplicit('AN' . 11,$yyzsl_zong_count , \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
$worksheet->setCellValueExplicit('AO' . 11,round($zhunshilv, 2) , \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
$worksheet->getStyle('AL11:AO' . 11)->applyFromArray($styleArray);
//新建Sheet2
$worksheet2 = new \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet($spreadsheet, 'Sheet2');
$spreadsheet->addSheet($worksheet2);
$worksheet2->setCellValue('A1', 'Foo');
$worksheet2->setCellValue('B1', 'Bar');
$file_name = Str::orderedUuid();
$dir_path = "public/excel/" . date('Ym') . '/' . $file_name;
Storage::makeDirectory($dir_path);
$name_date = date('n.j', strtotime($date . ' 00:00:00'));
$excel_path = $dir_path . "/体检报表-时间监控$name_date.xlsx";
$writer = new Xlsx($spreadsheet);
$writer->save(Storage::path($excel_path));
$url = Storage::url($excel_path);
return \Yz::Return(true,"获取成功",['url' => env('APP_URL').$url]);
}
}

@ -0,0 +1,122 @@
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\API\AspNetZhuanController;
use App\Http\Controllers\API\H5\OrderController;
use App\Http\Controllers\API\PEISApiController;
use App\Http\Controllers\API\XCXApiController;
use App\Services\ComboItemGroupService;
use App\Services\OrderService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
class TestController extends Controller
{
public function DBtest(){
//微信推送
// $data = [
// "ghzid" => "b3346cd4d63b49a58dbd9a41d69efde2",
// "yyid" => "6",
// "type" => "7",
// "msg1" => "张言",
// "msg2" => "2024-08-01 15:30",
// "msg3" => "影像科",
// "msg4" => "张医生",
// "msg5" => "请提前10分钟",
// "msg6" => "",
// "url" => ""
// ];
// $dnet = new AspNetZhuanController();
// $res = $dnet->WeiXinSend($data);
// dd($res);
// echo DB::table('users')->count();
// $dnet = new AspNetZhuanController();
// $res = $dnet->GetDoctorDateList([
// "yyid" => 6,
// "data" => ["2024-12-07","2024-12-08","2024-12-09","2024-12-10","2024-12-11","2024-12-12","2024-12-13","2024-12-14","2024-12-15","2024-12-16","2024-12-17","2024-12-18","2024-12-19","2024-12-20","2024-12-21","2024-12-22","2024-12-23","2024-12-24","2024-12-25","2024-12-26","2024-12-27","2024-12-28","2024-12-29","2024-12-30","2024-12-31","2025-01-01","2025-01-02","2025-01-03","2025-01-04","2025-01-05","2025-01-06"],
// "action" => "1"
// ]);
// return \Yz::Return(true,"",['data'=>$res]);
//退款------------------
// $data = [
// 'orderid' => '20241223082331336avdQwL',
// 'refund_order_id' => 'T' . '20241223082331336avdQwL',
// 'refund_amount' => 156190,
// 'refund_reason' => "体检H5订单退款",
// ];
// $XCX = new XCXApiController();
// $res = $XCX::Post('订单退款', $data);
// dd($res);
// if ($res['data']['refund_state'] != 'SUCCESS') {
// return \Yz::echoError1("退款失败" . $res['data']['refund_state']);
// }
//--------------
$aspnet=new AspNetZhuanController();
// $res=$aspnet::SendYanZhengMaCode(1,"19933509886");
// dd($res);
//优惠券-----------------
// $data=[
// 'action'=>4,
// 'ghzid'=>'3da338777513487fa65f918dad7719d8',
// 'dzjid'=>'995315997321979250097',
// 'hxbz'=>"H5撤销核销",
// 'yyid'=>6
// ];
// $aspnet::YouHuiQuan($data);
// $temp_list=[];
// $nmr=$aspnet::GetNmrList(['yyid'=>6,'data'=>['2024-10-25']],uniqid());
//
// //获取每日数量
// foreach($nmr as $k=>$v){
// $temp_list[]=[
// 'date'=>$k,
// 'count'=>count($v)
// ];
// }
//弃检
// $service = new ComboItemGroupService();
// dd($service->QiJian("2411090001","张三",['1812']));
// $peis = new PEISApiController();
// $data = [
// '电话号码' => "",
// '证件号码' => "",
// "预约Id"=>"3bcfa68d-8edd-40e6-a0ce-bca050be7961"
// ];
// $reports = $peis::Post('团检预约查询', 1, $data);
// dd($reports);
// //到检
// $aa=Http::post('https://tj-h5.hnxdfe.com/TJCheck',[
// 'password'=>'YRtA1rx1iWgbpYKX',
// 'exam_id'=>'2411280001',
// 'serve_id'=>''
// ]);
// dd($aa->json());
// $data=[
// 'action'=>4,
// 'ghzid'=>'5a798c097bc64bd79c22050175e6236a',
// 'dzjid'=>'994924890348203254993',
// 'hxbz'=>"H5撤销核销",
// 'yyid'=>6
// ];
// $aspnet::YouHuiQuan($data);
}
public function ApiTest(){
return \Yz::Return(true, '获取成功');
}
}

@ -0,0 +1,70 @@
<?php
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
/**
* The application's global HTTP middleware stack.
*
* These middleware are run during every request to your application.
*
* @var array<int, class-string|string>
*/
protected $middleware = [
// \App\Http\Middleware\TrustHosts::class,
\App\Http\Middleware\TrustProxies::class,
\Fruitcake\Cors\HandleCors::class,
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
];
/**
* The application's route middleware groups.
*
* @var array<string, array<int, class-string|string>>
*/
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
// \Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
'api' => [
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
'throttle:api',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
];
/**
* The application's route middleware.
*
* These middleware may be assigned to groups or used individually.
*
* @var array<string, class-string|string>
*/
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
'checktoken' => \App\Http\Middleware\CheckToken::class,
'log' => \App\Http\Middleware\Log::class,
'check.sign' => \App\Http\Middleware\CheckSign::class,
];
}

@ -0,0 +1,21 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
class Authenticate extends Middleware
{
/**
* Get the path the user should be redirected to when they are not authenticated.
*
* @param \Illuminate\Http\Request $request
* @return string|null
*/
protected function redirectTo($request)
{
if (! $request->expectsJson()) {
return route('login');
}
}
}

@ -0,0 +1,35 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class CheckSign
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle(Request $request, Closure $next)
{ //验证接口调用签名。md5后转大写time为时间戳
date_default_timezone_set('PRC');
$app_id=$request->input('app_id');
$time=$request->input('time'); //时间戳
$nonce=$request->input('nonce');
$sign=$request->input('sign');
$timeDiff = abs(time() - $time); // 获取时间差的绝对值
if ($timeDiff >= 600) return \Yz::echoError1('时间异常');
$cha_s=DB::table('outside_user')->where(['app_id'=>$app_id])->get();
if(!count($cha_s)==1) return \Yz::echoError1('第三方用户不存在');
$s_sign=strtoupper(md5($app_id.$time.$nonce.$cha_s[0]->app_secrect));
if($sign<>$s_sign) return \Yz::echoError1('签名验证失败');
return $next($request);
}
}

@ -0,0 +1,32 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use JWT;
class CheckToken
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle(Request $request, Closure $next)
{
$Authorization= $_SERVER['HTTP_AUTHORIZATION'];
$payload = JWT::CheckJwt($Authorization);
if($payload['status'] == 'OK')
{
$request->attributes->add($payload);//添加参数
return $next($request);
}else {
// return response()->json([$payload]);
return response($payload);
}
}
}

@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
class EncryptCookies extends Middleware
{
/**
* The names of the cookies that should not be encrypted.
*
* @var array<int, string>
*/
protected $except = [
//
];
}

@ -0,0 +1,87 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use App\Services\LogService;
class Log
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle(Request $request, Closure $next)
{
$insert_id=0;
$insert_id=self::requestLog($request,$insert_id); //记录请求时日志,不含返回信息
$response = $next($request);
$content = $response->getContent();
$data = json_decode($content, true); // 解码响应内容为关联数组
// 在关联数组中添加 code 字段
// $data['code'] = 200;
$data['code'] = $response->getStatusCode();
$modifiedContent = json_encode($data,JSON_UNESCAPED_UNICODE); // 编码修改后的关联数组为 JSON 字符串
$response->setContent($modifiedContent);
if(env('REQUEST_LOG') and $response->getStatusCode()==200){ //如果返回状态为200进行log
$ip=self::getTrustedProxiesIp(); //真实ip
$request_header=$request->header(); //请求头
// dd($response);
$response_data = $response->getData(); //返回data,json格式
$post_data=$request->post(); //post请求数据
$get_data=$request->query(); //get请求
$request_url=$request->getPathInfo();//访问的接口地址
$log=app()->make(LogService::class);
$log->RequestLog([
'ip'=>$ip,
'response_data'=>$response_data,
'request_header'=>$request_header,
'post_data'=>$post_data,
'get_data'=>$get_data,
'request_url'=>$request_url,
],$insert_id);
}
return $response;
}
public static function getTrustedProxiesIp(){ //获取用户真实ip
if (getenv('HTTP_CLIENT_IP') && strcasecmp(getenv('HTTP_CLIENT_IP'), 'unknown')) {
$ip = getenv('HTTP_CLIENT_IP');
} elseif (getenv('HTTP_X_FORWARDED_FOR') && strcasecmp(getenv('HTTP_X_FORWARDED_FOR'), 'unknown')) {
$ip = getenv('HTTP_X_FORWARDED_FOR');
} elseif (getenv('REMOTE_ADDR') && strcasecmp(getenv('REMOTE_ADDR'), 'unknown')) {
$ip = getenv('REMOTE_ADDR');
} elseif (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], 'unknown')) {
$ip = $_SERVER['REMOTE_ADDR'];
}
$res = preg_match('/[\d\.]{7,15}/', $ip, $matches) ? $matches [0] : '';
return $res;
}
public static function requestLog($request,$insert_id){ //记录请求时日志,不含返回信息
if(env('REQUEST_LOG') ){ //如果返回状态为200进行log
$ip=self::getTrustedProxiesIp(); //真实ip
$request_header=$request->header(); //请求头
$post_data=$request->post(); //post请求数据
$get_data=$request->query(); //get请求
$request_url=$request->getPathInfo();//访问的接口地址
$log=app()->make(LogService::class);
return $log->RequestLog([
'ip'=>$ip,
'request_header'=>$request_header,
'post_data'=>$post_data,
'get_data'=>$get_data,
'request_url'=>$request_url,
],$insert_id);
}
}
}

@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
class PreventRequestsDuringMaintenance extends Middleware
{
/**
* The URIs that should be reachable while maintenance mode is enabled.
*
* @var array<int, string>
*/
protected $except = [
//
];
}

@ -0,0 +1,32 @@
<?php
namespace App\Http\Middleware;
use App\Providers\RouteServiceProvider;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @param string|null ...$guards
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle(Request $request, Closure $next, ...$guards)
{
$guards = empty($guards) ? [null] : $guards;
foreach ($guards as $guard) {
if (Auth::guard($guard)->check()) {
return redirect(RouteServiceProvider::HOME);
}
}
return $next($request);
}
}

@ -0,0 +1,19 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
class TrimStrings extends Middleware
{
/**
* The names of the attributes that should not be trimmed.
*
* @var array<int, string>
*/
protected $except = [
'current_password',
'password',
'password_confirmation',
];
}

@ -0,0 +1,20 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Http\Middleware\TrustHosts as Middleware;
class TrustHosts extends Middleware
{
/**
* Get the host patterns that should be trusted.
*
* @return array<int, string|null>
*/
public function hosts()
{
return [
$this->allSubdomainsOfApplicationUrl(),
];
}
}

@ -0,0 +1,28 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Http\Middleware\TrustProxies as Middleware;
use Illuminate\Http\Request;
class TrustProxies extends Middleware
{
/**
* The trusted proxies for this application.
*
* @var array<int, string>|string|null
*/
protected $proxies;
/**
* The headers that should be used to detect proxies.
*
* @var int
*/
protected $headers =
Request::HEADER_X_FORWARDED_FOR |
Request::HEADER_X_FORWARDED_HOST |
Request::HEADER_X_FORWARDED_PORT |
Request::HEADER_X_FORWARDED_PROTO |
Request::HEADER_X_FORWARDED_AWS_ELB;
}

@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
class VerifyCsrfToken extends Middleware
{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array<int, string>
*/
protected $except = [
'*'
];
}

@ -0,0 +1,66 @@
<?php
namespace App\Lib;
class HSM
{
protected static $baseurl="http://223.70.139.221:2018";
protected static $keyIndex=1;
protected static $encAlg="SM4/CBC/PKCS5Padding";
protected static $iv="31323334353637383132333435363738";
//加密
public static function HsmEncrypt($str){
$str = bin2hex($str);
$url= self::$baseurl."/api/hsm/sym/symEncryptInternalForKEK";
$data=[
"keyIndex"=>self::$keyIndex,
"encAlg"=>self::$encAlg,
"iv"=>self::$iv,
"plainData"=>$str
];
$data=json_encode($data);
$encryptStr=self::post($url,$data);
$r_data=json_decode($encryptStr, true);
// dd($r_data);
if($r_data['status']==0){
return ['encrypt_str'=>$r_data['body']['cipherData'],'status'=>true];
}else{
return ['status'=>false];
}
}
//解密
public static function HsmDecrypt($str){
$url= self::$baseurl."/api/hsm/sym/symDecryptInternalForKEK";
$data=[
"keyIndex"=>self::$keyIndex,
"encAlg"=>self::$encAlg,
"iv"=>self::$iv,
"cipherData"=>$str
];
$data=json_encode($data);
$encryptStr=self::post($url,$data);
$r_data=json_decode($encryptStr, true);
if($r_data['status']==0){
return ['decrypt_str'=>hex2bin($r_data['body']['plain']),'status'=>true];
}else{
return ['status'=>false];
}
}
public function post($url, $data_string)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Content-Type: application/json; charset=utf-8',
'Content-Length: ' . strlen($data_string)
]);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);
$r = curl_exec($curl);
curl_close($curl);
return $r;
}
}

@ -0,0 +1,132 @@
<?php
/**
* Created by PhpStorm.
* User: yanzai
* Date: 2018/12/4
* Time: 13:53
* 刚发现jwt ,自己理解的是jwt就是一个加密思路虽然按照规定写了但是还是认为可以随意或许以后能明白真正的Jwt
*/
class JWT
{
//设置Jwt秘钥
public static function GetSecret()
{
return env('JWT_KEY');
}
public static function GetGetSecretTimeOut()
{
date_default_timezone_set('PRC'); //token的有效期
$mm=env('JWT_TIME_OUT')*60;//PHP的时间是按秒算的
return date("Y-m-d H:i:s",strtotime(date('Y-m-d H:i:s',time()))+$mm); //设置Token超时时间 单位:分钟
}
public static function GetRefreshTokenTimeOut() //刷新token的有效期
{
date_default_timezone_set('PRC');
$mm=env('JWT_REFRESH_TIME_OUT')*60;//PHP的时间是按秒算的
return date("Y-m-d H:i:s",strtotime(date('Y-m-d H:i:s',time()))+$mm); //设置RefreshToken超时时间 单位:分钟
}
public static function GetMian7TokenTimeOut() //免登录7天token的有效期
{
date_default_timezone_set('PRC');
$mm=10080*60;//PHP的时间是按秒算的
return date("Y-m-d H:i:s",strtotime(date('Y-m-d H:i:s',time()))+$mm); //设置RefreshToken超时时间 单位:分钟
}
//构建完整 JWT
public static function BuildJWT($send_user,$tokenType,$userid,$role,$exp)
{
$head = self::BuildHead();
$payload = self::BuildPayload($send_user,$tokenType,$userid,$role,$exp);
$signature = self::BuildSignature($head,$payload);
return $head.'.'.$payload.'.'.$signature;
}
//构建jwt head base64转码
public static function BuildHead()
{
$head = self::urlsafe_b64encode('{
"alg": "sha256",
"typ": "JWT"
}');
return $head;
}
//构建jwt Payload base64转码
public static function BuildPayload($send_user,$tokenType,$userid,$role='customer',$exp)
{
$payload = self::urlsafe_b64encode('{"senduser": "'.$send_user.'","tokentype": "'.$tokenType.'","userid": "'.$userid.'","role": "'.$role.'","exp": "'.$exp.'"}');
return $payload;
}
//构建jwt Signature 加密生成签名
public static function BuildSignature($head,$payload)
{
$s = hash_hmac('sha256', $head.'.'.$payload, self::GetSecret(), true);
return self::urlsafe_b64encode($s);
}
//验证JWT
public static function CheckJwt($code)
{
$code = substr($code,strpos($code,' ')+1);
$result = array();
if(strlen($code)<10)
{
$result['status']='Toke_Error';
$result['meg']= '签名异常,拒绝操作!';
$result['code']=10001;
return $result;
}
$array=explode('.', $code);
$ReceiveSignature = $array[2];
$ReceiveHead = $array[0];
$ReceivePayload = $array[1];
$Signature = self::BuildSignature($ReceiveHead,$ReceivePayload);
if($ReceiveSignature==$Signature) //判断签名是否一致
{
$payload_string = self::urlsafe_b64decode($ReceivePayload);
$payload=json_decode($payload_string,true);
date_default_timezone_set('PRC');
if($payload['exp']>date('Y-m-d H:i:s',time())) //判断Token是否过期
{
$result['status']='OK';
$result['tokentype']=$payload['tokentype'];
$result['role']=$payload['role'];
$result['userid']=$payload['userid'];
$result['meg']= 'Token验证通过';
}else{
$result['status']='Token_TimeOut';
$result['meg']= 'Token已过期请返回登录界面重新授权';
$result['code']=10002;
}
}
else{
$result['status']='Toke_Error';
$result['meg']= '签名异常,拒绝操作!';
$result['code']=10001;
}
return $result;
}
//URL安全的字符串编码
static function urlsafe_b64encode($string) {
$data = base64_encode($string);
$data = str_replace(array('+','/','='),array('-','_',''),$data);
return $data;
}
//URL安全的字符串解码
static function urlsafe_b64decode($string) {
$data = str_replace(array('-','_'),array('+','/'),$string);
$mod4 = strlen($data) % 4;
if ($mod4) {
$data .= substr('====', $mod4);
}
return base64_decode($data);
}
}

@ -0,0 +1,72 @@
<?php
namespace App\Lib;
use DateTime;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
class Tools
{
//查询某天是星期几
public static function GetWeekName($date)
{
$dayOfWeek = date('N', strtotime($date)); // 获取星期几1代表星期一7代表星期日
$weekname='';
switch ($dayOfWeek) {
case 1:
$weekname= "星期一";
break;
case 2:
$weekname= "星期二";
break;
case 3:
$weekname="星期三";
break;
case 4:
$weekname= "星期四";
break;
case 5:
$weekname= "星期五";
break;
case 6:
$weekname= "星期六";
break;
case 7:
$weekname= "星期日";
break;
default:
$weekname= "无效日期";
}
return $weekname;
}
public static function SendMsg($r_yyid,$tel,$name,$time){
if($r_yyid==1){
$yyid=6;
}
if($r_yyid==4){
$yyid=2;
}
$content="时间:".$time.";科室:健康管理中心1区。温馨提醒:您的预约已成功,请在预约时间前 30 分钟达到科室凭身份证原件开单。建议您体检前3天清淡饮食、禁烟酒";
$url="http://220.174.210.111:82/tuisong.aspx?yyid=".$yyid."&type=8&mobile=".$tel."&msg1=".urlencode($name)."&msg2=".urlencode($content);
$response = Http::get($url);
if ($response->successful()) {
}else{
Log::info("短信发送失败");
}
}
//根据生日 获取年龄
public static function GetAge($birthday) {
$dob = new DateTime($birthday);
$now = new DateTime();
// 计算两个日期之间的差值
$interval = $now->diff($dob);
// 返回年龄
return $interval->y;
}
}

@ -0,0 +1,97 @@
<?php
namespace App\Lib;
class UKEY
{
protected static $url="http://223.70.139.221:18088";
protected static $appName="SVSDefault";
public static function GetServerInfo(){
$info=[];
$c=[
'appName'=>self::$appName,
'length'=>16
];
$random='';
$res=self::post(self::$url.'/api/common/genRandom',json_encode($c));//获取随机数
if($res['status']==0){
$random=$res['body']['random'];
$info['random']=$random;
$info['signData']=self::signData($random);
$info['serverCert']=self::GetServerCert();
}
return $info;
}
//数据签名
public static function signData($oriData){
$c=[
'appName'=>self::$appName,
'oriData'=>$oriData
];
$sign='';
$res=self::post(self::$url.'/api/pkcs1/signData',json_encode($c));
if($res['status']==0){
$sign=$res['body']['p1Sign'];
}
return $sign;
}
//获取服务器证书
public static function GetServerCert(){
$c=[
'appName'=>self::$appName,
];
$cert='';
$res=self::post(self::$url.'/api/cert/getServerCertificate',json_encode($c));
if($res['status']==0){
$cert=$res['body']['base64Cert'];
}
return $cert;
}
//服务端验证客户端证书有效性,证书有效返回1,证书无效情况下:-1为不是所信任的根-2为超过
//有效期,-3为作废证书-4已加入黑名单-5证书未生效, 0 未知错误
public static function CheckCert($cert){
$c=[
'appName'=>self::$appName,
'cert'=>$cert
];
$validRes='';
$res=self::post(self::$url.'/api/cert/validateCert',json_encode($c));
if($res['status']==0){
$validRes=$res['body']['validRes'];
}
return $validRes;
}
//验证数据签名 返回数据签名验证结果,true 验证通过false 验证失败
public static function CheckSign($cert,$oriData,$sign){
$c=[
'appName'=>self::$appName,
'cert'=>$cert,
'oriData'=>$oriData,
'sign'=>$sign
];
$validRes=false;
$res=self::post(self::$url.'/api/pkcs1/verifySignData',json_encode($c));
if($res['status']==0){
$validRes=$res['body']['verifyRes'];
}
return $validRes;
}
public function post($url, $data_string)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Content-Type: application/json; charset=utf-8',
'Content-Length: ' . strlen($data_string)
]);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);
$r = curl_exec($curl);
curl_close($curl);
return json_decode($r,true);
}
}

@ -0,0 +1,107 @@
<?php
namespace App\Lib;
class XTSign
{
const Appid="APP_7B3F36A14E99410A80B37AEF332E3247";
const Key="DLwiH46Esb8ccNTkuSSVAadNTWUfW0sc";
const BaseUrl="https://newcoss-dev.isignet.cn:10201";
const ApiList=[
'register'=>self::BaseUrl."/coss/service/v1/addUser", //注册
'getAuthCode'=>self::BaseUrl."/coss/service/v1/getAuthCode", //产生激活码
'addSignJob'=>self::BaseUrl."/coss/service/v1/addSignJob", //添加签名任务
'verifySignData'=>self::BaseUrl."/coss/service/v1/verifySignData", //验签接口 3.4.9.3
'getCertInfo'=>self::BaseUrl."/coss/service/v1/getCertInfo", //解析证书信息
];
//系统签名接口调用
public static function XTRequest($url,$data){
if(!isset(self::ApiList[$url])) return \Yz::echoError1("接口不存在");
$url= self::ApiList[$url];
$baseData=[
"version"=>"1.0",
"appId"=>self::Appid,
"signAlgo"=>"HMAC",
];
$data=array_merge($baseData, $data);
$sign=self::Sign($data);
$data= array_merge($data,['signature'=>$sign]);
// dd($data);
$data=json_encode($data);
$encryptStr=self::post($url,$data);
$r_data=json_decode($encryptStr, true);
if($r_data['status']==200){
return \Yz::Return(true,$r_data['message'],$r_data['data']);
}else{
return \Yz::echoError1($r_data['message']);
}
}
//产生激活码
// public static function getAuthCode(){
// $url= self::$baseUrl."/coss/service/v1/getAuthCode";
// $data=[
// "version"=>"1.0",
// "appId"=>self::$appid,
// "signAlgo"=>"HMAC",
// "userId"=>"915b164cd8e883f7fb289e3bcf34ac68d971c7e1058f18bcb24ad33ec7a201e1",
// ];
// $sign=self::Sign($data);
// $data= array_merge($data,['signature'=>$sign]);
// // dd($data);
// $data=json_encode($data);
// $encryptStr=self::post($url,$data);
// $r_data=json_decode($encryptStr, true);
//
// return $r_data;
// }
public static function Sign($parameters){
// 定义 M 集合内的参数值
// $parameters = array(
// "key1" => "value1",
// "key2" => "value2",
// // ...
// );
// 按照参数名的 ASCII 码从小到大排序
ksort($parameters);
// 拼接参数为 URL 键值对字符串
$stringA = "";
foreach ($parameters as $key => $value) {
if ($value === "") {
// 参数值为空,进行相应的处理
// 比如跳过该参数或者抛出异常
continue;
}
$stringA .= $key . "=" . $value . "&";
}
$stringA = rtrim($stringA, "&");
// HMAC 运算
$secretKey =self::Key;
$signature = base64_encode(hash_hmac("sha256", $stringA, $secretKey, true));
return $signature;
}
public function post($url, $data_string)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Content-Type: application/json; charset=utf-8',
'Content-Length: ' . strlen($data_string)
]);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);
$r = curl_exec($curl);
curl_close($curl);
return $r;
}
}

@ -0,0 +1,37 @@
<?php
use Illuminate\Http\Exceptions\HttpResponseException;
class Yz{
public static function echo($data=[],$code=200){
$result=array();
$result['code']=$code;
$result['data']=$data;
return response()->json($result)->setEncodingOptions(JSON_UNESCAPED_UNICODE);
}
public static function echoError($msg){
$result=array();
$result['status']='no';
$result['msg']=$msg;
return response()->json($result)->setEncodingOptions(JSON_UNESCAPED_UNICODE);
}
public static function echoError1($msg){
$result=array();
$result['status']=false;
$result['msg']=$msg;
return response()->json($result)->setEncodingOptions(JSON_UNESCAPED_UNICODE);
}
public static function Return($status,$msg,$data=[]){
$result=array();
$result['status']=$status;
$result['msg']=$msg;
$result['data']=$data;
return response()->json($result)->setEncodingOptions(JSON_UNESCAPED_UNICODE);
// return $result;
}
public static function debug($data)
{
throw new HttpResponseException(response()->json(['status' => true, 'data' => $data])->setEncodingOptions(JSON_UNESCAPED_UNICODE));
}
}

@ -0,0 +1,10 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class FenzhenLog extends Model
{
use HasFactory;
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save