build
parent
c8d9667d2e
commit
423f00b97e
|
|
@ -29,7 +29,7 @@ class TotalPatientController extends AdminController
|
|||
$this->exportAction(),
|
||||
])
|
||||
->filter($this->baseFilter()->actions()->body([
|
||||
amisMake()->SelectControl()->options($this->getPatientOptions())->searchable()->name('id')->label(__('total-record.name'))->size('md')->clearable(),
|
||||
amisMake()->SelectControl()->options($this->getPatientOptions())->searchable()->name('id')->label(__('total-record.name'))->size('md')->multiple()->clearable(),
|
||||
amisMake()->SelectControl()->options($this->getTypeOptions())->name('type_id')->label(__('patient-record.type_id'))->size('md')->clearable(),
|
||||
amisMake()->DateRangeControl()->name('treat_range')->label(__('total-record.treat_at'))->clearable()->size('md'),
|
||||
// amisMake()->Button()->label(__('admin.reset'))->actionType('clear-and-submit'),
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class TotalProfitController extends AdminController
|
|||
$this->exportAction(),
|
||||
])
|
||||
->filter($this->baseFilter()->actions()->body([
|
||||
amisMake()->SelectControl()->options($this->getAdminUserOptions())->searchable()->name('id')->label(__('total-profit.id'))->clearable()->size('md'),
|
||||
amisMake()->SelectControl()->options($this->getAdminUserOptions())->searchable()->name('id')->label(__('total-profit.id'))->multiple()->clearable()->size('md'),
|
||||
amisMake()->SelectControl()->options($this->getTypeOptions())->name('type_id')->label(__('total-profit.type_id'))->size('md')->clearable(),
|
||||
amisMake()->DateRangeControl()->name('treat_range')->label(__('total-record.treat_at'))->clearable()->size('md'),
|
||||
// amisMake()->Button()->label(__('admin.reset'))->actionType('clear-and-submit'),
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Admin\Services;
|
||||
|
||||
use App\Enums\Gender;
|
||||
use App\ModelFilters\PatientFilter;
|
||||
use Illuminate\Validation\Rule;
|
||||
use App\Models\{Patient, PatientRecord};
|
||||
|
|
@ -42,6 +43,11 @@ class PatientService extends BaseService
|
|||
if ($images = data_get($data, 'images')) {
|
||||
$data['images'] = is_array($images) ? $images : explode(',', $images);
|
||||
}
|
||||
if (!$model) {
|
||||
if (!data_get($data, 'sex')) {
|
||||
$data['sex'] = Gender::None;
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
|
@ -58,15 +64,15 @@ class PatientService extends BaseService
|
|||
$createRule = [
|
||||
'type_id' => 'required',
|
||||
'name' => 'required',
|
||||
'user_id' => $userRule->where('type_id', data_get($data, 'type_id'))
|
||||
'user_id' => ['nullable', $userRule->where('type_id', data_get($data, 'type_id'))],
|
||||
];
|
||||
$updateRule = [
|
||||
'user_id' => $userRule->where('type_id', data_get($data, 'type_id', $model?->type_id))
|
||||
'user_id' => ['nullable', $userRule->where('type_id', data_get($data, 'type_id', $model?->type_id))]
|
||||
];
|
||||
$validator = Validator::make($data, $model ? $updateRule : $createRule, [
|
||||
'type_id.required' => __('patient.type_id') . '必填',
|
||||
'name.required' => __('patient.name') . '必填',
|
||||
'user_id.unique' => __('patient.user_id') . '已经存在',
|
||||
'user_id.unique' => __('patient.user_id') . '已经绑定过',
|
||||
]);
|
||||
if ($validator->fails()) {
|
||||
return $validator->errors()->first();
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ class TotalProfitService extends BaseService
|
|||
}
|
||||
$request = request();
|
||||
if ($request->filled('id')) {
|
||||
$query->where('id', $request->input('id'));
|
||||
$id = $request->input('id');
|
||||
$query->whereIn('id', is_array($id) ? $id : explode(',', $id));
|
||||
}
|
||||
$subQuery = fn ($q) => $q->filter(request()->except(['id']));
|
||||
$query->select(['id', 'name'])->with([
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ class UserService extends BaseService
|
|||
}
|
||||
|
||||
if ($filter) {
|
||||
logger('request', request()->input());
|
||||
$query->filter(request()->input(), $filter);
|
||||
}
|
||||
|
||||
|
|
@ -44,7 +45,7 @@ class UserService extends BaseService
|
|||
], [
|
||||
'phone.required' => __('user.phone') . '必填',
|
||||
'phone.phone' => __('user.phone') . ' 不是合法手机号',
|
||||
'phone.unique' => __('user.phone') . '已经存在',
|
||||
'phone.unique' => __('user.phone') . '已经注册',
|
||||
]);
|
||||
if ($validator->fails()) {
|
||||
return $validator->errors()->first();
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use App\Http\Controllers\Controller;
|
|||
use App\Models\User;
|
||||
use App\Models\UserSocialite;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class AuthController extends Controller
|
||||
|
|
@ -41,20 +42,27 @@ class AuthController extends Controller
|
|||
|
||||
public function register(Request $request)
|
||||
{
|
||||
$service = UserService::make();
|
||||
if (!$service->store($request->all())) {
|
||||
throw new BaseException($service->getError());
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
$service = UserService::make();
|
||||
if (!$service->store($request->all())) {
|
||||
throw new BaseException($service->getError());
|
||||
}
|
||||
$user = User::where('phone', $request->input('phone'))->first();
|
||||
// 更新第三方账户
|
||||
$openid = $request->input('openid');
|
||||
$open_type = $request->input('open_type');
|
||||
if ($openid && $open_type) {
|
||||
UserSocialite::where(['openid' => $openid, 'type' => SocialiteType::from($open_type), 'user_type' => $user->getMorphClass()])->update([
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
}
|
||||
DB::commit();
|
||||
$token = $user->createToken('client')->plainTextToken;
|
||||
return $this->response()->success(['token' => $token, 'user' => $user]);
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
return $this->response()->fail($e->getMessage());
|
||||
}
|
||||
$user = User::where('phone', $request->input('phone'))->first();
|
||||
// 更新第三方账户
|
||||
$openid = $request->input('openid');
|
||||
$open_type = $request->input('open_type');
|
||||
if ($openid && $open_type) {
|
||||
UserSocialite::where(['openid' => $openid, 'type' => SocialiteType::from($open_type), 'user_type' => $user->getMorphClass()])->update([
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
}
|
||||
$token = $user->createToken('client')->plainTextToken;
|
||||
return $this->response()->success(['token' => $token, 'user' => $user]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@ class UserFilter extends ModelFilter
|
|||
$this->where(fn ($q) => $q->where('phone', 'like', $str)->orWhere('name', 'like', $str));
|
||||
}
|
||||
|
||||
public function ignoreType($key)
|
||||
public function treatType($key)
|
||||
{
|
||||
$this->whereDoesntHave('patients', fn ($q) => $q->where('type_id', $key));
|
||||
$this->whereHas('patients', fn ($q) => $q->where('type_id', '!=', $key));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
<!doctype html><html lang="zh-CN"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>宝芝堂</title><script>var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)'))
|
||||
document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')</script><link rel="stylesheet" href="/client/static/index.5841170f.css"/><script defer="defer" src="/client/static/js/chunk-vendors.40c214d6.js"></script><script defer="defer" src="/client/static/js/index.9ce0c3de.js"></script></head><body><noscript><strong>Please enable JavaScript to continue.</strong></noscript><div id="app"></div></body></html>
|
||||
document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')</script><link rel="stylesheet" href="/client/static/index.5841170f.css"/><script defer="defer" src="/client/static/js/chunk-vendors.40c214d6.js"></script><script defer="defer" src="/client/static/js/index.3273abba.js"></script></head><body><noscript><strong>Please enable JavaScript to continue.</strong></noscript><div id="app"></div></body></html>
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -1,2 +1,2 @@
|
|||
<!doctype html><html lang="zh-CN"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>宝芝堂</title><script>var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)'))
|
||||
document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')</script><link rel="stylesheet" href="/h5/static/index.5841170f.css"/><script defer="defer" src="/h5/static/js/chunk-vendors.7eabb1da.js"></script><script defer="defer" src="/h5/static/js/index.1964f9fd.js"></script></head><body><noscript><strong>Please enable JavaScript to continue.</strong></noscript><div id="app"></div></body></html>
|
||||
document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')</script><link rel="stylesheet" href="/h5/static/index.5841170f.css"/><script defer="defer" src="/h5/static/js/chunk-vendors.7eabb1da.js"></script><script defer="defer" src="/h5/static/js/index.b5e1a8df.js"></script></head><body><noscript><strong>Please enable JavaScript to continue.</strong></noscript><div id="app"></div></body></html>
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -3,6 +3,7 @@
|
|||
namespace Tests\Feature;
|
||||
|
||||
// use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use App\Admin\Services\UserService;
|
||||
use Overtrue\EasySms\EasySms;
|
||||
use Tests\TestCase;
|
||||
|
||||
|
|
@ -13,17 +14,8 @@ class ExampleTest extends TestCase
|
|||
*/
|
||||
public function test_the_application_returns_a_successful_response(): void
|
||||
{
|
||||
$now = now();
|
||||
dump($now->day, $now->month);
|
||||
// try {
|
||||
// $easySms = new EasySms(config('easysms'));
|
||||
// $result = $easySms->send('18983405554', [
|
||||
// 'template' => 'SMS_463637721',
|
||||
// ]);
|
||||
// dump($result);
|
||||
// } catch (\Exception $e) {
|
||||
// dump($e->getException('aliyun')->raw);
|
||||
// }
|
||||
$filters = ['ignore_type_id' => 2];
|
||||
dump((new UserService())->list());
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue