main
commit
5887857ea6
@ -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
|
||||
@ -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,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,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,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,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,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,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,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,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,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,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,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,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…
Reference in New Issue