You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
173 lines
6.7 KiB
PHP
173 lines
6.7 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\HospitalExtra;
|
|
use Illuminate\Http\Request;
|
|
use Login;
|
|
use Yo;
|
|
|
|
class HospitalExtraController extends Controller
|
|
{
|
|
public function get_hospital_extra($hospital, $mark)
|
|
{
|
|
$hospital_extra = HospitalExtra::where('hospital', $hospital)->where('mark', $mark)->first();
|
|
if (!$hospital_extra) {
|
|
$hospital_extra = new HospitalExtra();
|
|
$hospital_extra->hospital = $hospital;
|
|
$hospital_extra->mark = $mark;
|
|
switch ($mark) {
|
|
case 'pay':
|
|
$hospital_extra->content = '{"wxp":{"open":0,"id":"","number":"","v3":"","key":"","crt":""}}';
|
|
break;
|
|
case 'order_type':
|
|
$hospital_extra->content = '{"combo_add_item":0,"item":0}';
|
|
break;
|
|
case 'card_pay':
|
|
$hospital_extra->content = '{"open":0}';
|
|
break;
|
|
case 'readme':
|
|
$hospital_extra->content = '{"open":0,"content":"","time":5}';
|
|
break;
|
|
case 'h5txt':
|
|
$hospital_extra->content = '{"path":""}';
|
|
break;
|
|
case 'report':
|
|
$hospital_extra->content = '{"open":0}';
|
|
break;
|
|
case 'profitsharing':
|
|
$hospital_extra->content = '{"open":0}';
|
|
break;
|
|
}
|
|
$hospital_extra->save();
|
|
}
|
|
$hospital_extra->content = json_decode($hospital_extra->content, true);
|
|
return $hospital_extra;
|
|
}
|
|
|
|
public function update(Request $request)
|
|
{
|
|
Login::admin([], [17, 25]);
|
|
$hospital = $request->post('hospital');
|
|
if (Login::$info->hospital != 0) {
|
|
if ($hospital != Login::$info->hospital) {
|
|
Yo::error_echo(100000, ['机构/医院']);
|
|
}
|
|
}
|
|
$mark = $request->post('mark');
|
|
$content = $request->post('content');
|
|
$hospital_extra = self::get_hospital_extra($hospital, $mark);
|
|
$hospital_extra->content = $content;
|
|
$hospital_extra->save();
|
|
return Yo::update_echo($hospital_extra->id);
|
|
}
|
|
|
|
public function info(Request $request)
|
|
{
|
|
Login::admin([], [17, 25]);
|
|
$hospital = $request->post('hospital');
|
|
if (Login::$info->hospital != 0) {
|
|
if ($hospital != Login::$info->hospital) {
|
|
Yo::error_echo(100000, ['机构/医院']);
|
|
}
|
|
}
|
|
$mark = $request->post('mark');
|
|
$hospital_extra = self::get_hospital_extra($hospital, $mark);
|
|
return Yo::echo([
|
|
'info' => $hospital_extra
|
|
]);
|
|
}
|
|
|
|
public function report_status(Request $request)
|
|
{
|
|
$hospital = $request->post('hospital');
|
|
$mark = 'report';
|
|
$hospital_extra = HospitalExtra::where('hospital', $hospital)->where('mark', $mark)->first();
|
|
$hospital_extra_public = HospitalExtra::where('hospital', 0)->where('mark', $mark)->first();
|
|
$hospital_extra_public_content = json_decode($hospital_extra_public->content, true);
|
|
if (!!$hospital_extra) {
|
|
$hospital_extra_content = json_decode($hospital_extra->content, true);
|
|
$hospital_extra_content['open'] = $hospital_extra_content['open'] == 0 ? $hospital_extra_public_content['open'] : $hospital_extra_content['open'];
|
|
} else {
|
|
$hospital_extra_content = $hospital_extra_public_content;
|
|
}
|
|
if ($hospital_extra_content['open'] == 0) $hospital_extra_content['open'] = 2;
|
|
return Yo::echo([
|
|
'info' => $hospital_extra_content
|
|
]);
|
|
}
|
|
|
|
|
|
public function profitsharing_status(Request $request)
|
|
{
|
|
$hospital = $request->post('hospital');
|
|
$mark = 'profitsharing';
|
|
$hospital_extra = HospitalExtra::where('hospital', $hospital)->where('mark', $mark)->first();
|
|
$hospital_extra_public = HospitalExtra::where('hospital', 0)->where('mark', $mark)->first();
|
|
$hospital_extra_public_content = json_decode($hospital_extra_public->content, true);
|
|
if (!!$hospital_extra) {
|
|
$hospital_extra_content = json_decode($hospital_extra->content, true);
|
|
$hospital_extra_content['open'] = $hospital_extra_content['open'] == 0 ? $hospital_extra_public_content['open'] : $hospital_extra_content['open'];
|
|
} else {
|
|
$hospital_extra_content = $hospital_extra_public_content;
|
|
}
|
|
if ($hospital_extra_content['open'] == 0) $hospital_extra_content['open'] = 2;
|
|
return Yo::echo([
|
|
'info' => $hospital_extra_content
|
|
]);
|
|
}
|
|
|
|
public function mp_info(Request $request)
|
|
{
|
|
Login::user();
|
|
$hospital = $request->post('hospital');
|
|
$mark = $request->post('mark');
|
|
$hospital_extra = HospitalExtra::where('hospital', $hospital)->where('mark', $mark)->first();
|
|
$hospital_extra_public = HospitalExtra::where('hospital', 0)->where('mark', $mark)->first();
|
|
$hospital_extra_public_content = json_decode($hospital_extra_public->content, true);
|
|
if (!!$hospital_extra) {
|
|
$hospital_extra_content = json_decode($hospital_extra->content, true);
|
|
switch ($mark) {
|
|
case 'pay':
|
|
$hospital_extra_content['wxp'] = $hospital_extra_content['wxp']['open'] == 0 ? $hospital_extra_public_content['wxp'] : $hospital_extra_content['wxp'];
|
|
break;
|
|
case 'order_type':
|
|
$hospital_extra_content['combo_add_item'] = $hospital_extra_content['combo_add_item'] == 0 ? $hospital_extra_public_content['combo_add_item'] : $hospital_extra_content['combo_add_item'];
|
|
$hospital_extra_content['item'] = $hospital_extra_content['item'] == 0 ? $hospital_extra_public_content['item'] : $hospital_extra_content['item'];
|
|
break;
|
|
case 'card_pay':
|
|
case 'report':
|
|
case 'profitsharing':
|
|
$hospital_extra_content['open'] = $hospital_extra_content['open'] == 0 ? $hospital_extra_public_content['open'] : $hospital_extra_content['open'];
|
|
break;
|
|
case 'readme':
|
|
$hospital_extra_content['open'] = $hospital_extra_content['open'] == 0 ? $hospital_extra_public_content['open'] : $hospital_extra_content['open'];
|
|
$hospital_extra_content['content'] = $hospital_extra_content['content'] == '' ? $hospital_extra_public_content['content'] : $hospital_extra_content['content'];
|
|
$hospital_extra_content['time'] = $hospital_extra_content['time'] == 0 ? $hospital_extra_public_content['time'] : $hospital_extra_content['time'];
|
|
break;
|
|
}
|
|
} else {
|
|
$hospital_extra_content = $hospital_extra_public_content;
|
|
}
|
|
|
|
switch ($mark) {
|
|
case 'pay':
|
|
if ($hospital_extra_content['wxp']['open'] == 0) $hospital_extra_content['wxp']['open'] = 2;
|
|
break;
|
|
case 'order_type':
|
|
if ($hospital_extra_content['combo_add_item'] == 0) $hospital_extra_content['combo_add_item'] = 2;
|
|
if ($hospital_extra_content['item'] == 0) $hospital_extra_content['item'] = 2;
|
|
break;
|
|
case 'card_pay':
|
|
case 'readme':
|
|
case 'report':
|
|
case 'profitsharing':
|
|
if ($hospital_extra_content['open'] == 0) $hospital_extra_content['open'] = 2;
|
|
break;
|
|
}
|
|
return Yo::echo([
|
|
'info' => $hospital_extra_content
|
|
]);
|
|
}
|
|
}
|