|
|
|
|
@ -5,6 +5,7 @@ namespace App\Http\Controllers\Customer;
|
|
|
|
|
|
|
|
|
|
use App\Models\Area;
|
|
|
|
|
use App\Models\Balance;
|
|
|
|
|
use App\Models\Bed;
|
|
|
|
|
use App\Models\Building;
|
|
|
|
|
use App\Models\Factor;
|
|
|
|
|
use App\Models\FactorItems;
|
|
|
|
|
@ -19,6 +20,7 @@ use App\Models\Project;
|
|
|
|
|
use App\Models\Recharge;
|
|
|
|
|
use Carbon\Carbon;
|
|
|
|
|
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
|
|
|
|
class OrdersController extends CommonController
|
|
|
|
|
@ -69,8 +71,8 @@ class OrdersController extends CommonController
|
|
|
|
|
public function getAreasByProject($id)
|
|
|
|
|
{
|
|
|
|
|
$buildings = (new Building())->where("project_id", $id)->with(["areas" => function ($query) {
|
|
|
|
|
$query->select("id","building_id","name","myindex")->orderBy("myindex");
|
|
|
|
|
}])->select("id","project_id","name","myindex")->orderBy("myindex")->get();
|
|
|
|
|
$query->select("id", "building_id", "name", "myindex")->orderBy("myindex");
|
|
|
|
|
}])->select("id", "project_id", "name", "myindex")->orderBy("myindex")->get();
|
|
|
|
|
return response()->json($buildings->toArray());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -90,14 +92,47 @@ class OrdersController extends CommonController
|
|
|
|
|
|
|
|
|
|
public function getBedsByArea($id)
|
|
|
|
|
{
|
|
|
|
|
$area = (new Area())->with(["beds"=>function($query) {
|
|
|
|
|
$query->with(["room"=>function($query) {
|
|
|
|
|
$query->select("id","name");
|
|
|
|
|
}])->select("id","name","area_id","room_id");
|
|
|
|
|
$area = (new Area())->with(["beds" => function ($query) {
|
|
|
|
|
$query->with(["room" => function ($query) {
|
|
|
|
|
$query->select("id", "name");
|
|
|
|
|
}])->select("id", "name", "area_id", "room_id");
|
|
|
|
|
}])->first();
|
|
|
|
|
return response()->json($area->beds->toArray());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @OA\Get(
|
|
|
|
|
* path="/customer/get-available-paramedics",
|
|
|
|
|
* summary="V2-获取可用护工列表(需完善)",
|
|
|
|
|
* description="获取可用护工列表",
|
|
|
|
|
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
|
|
|
|
|
* @OA\Parameter(name="bed_id", in="query", @OA\Schema(type="integer"), required=true, description="床位ID"),
|
|
|
|
|
* @OA\Parameter(name="sex", in="query", @OA\Schema(type="string"), required=true, description="性别:[男/女]"),
|
|
|
|
|
* @OA\Parameter(name="start_date", in="query", @OA\Schema(type="string"), required=false, description="日期,默认为当天"),
|
|
|
|
|
* @OA\Response(
|
|
|
|
|
* response="200",
|
|
|
|
|
* description="获取可用护工列表"
|
|
|
|
|
* )
|
|
|
|
|
* )
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public function getAvailableParamedics(Request $request)
|
|
|
|
|
{
|
|
|
|
|
//todo:更精准的筛选器
|
|
|
|
|
$bed = (new Bed())->find($request->bed_id);
|
|
|
|
|
|
|
|
|
|
$model = new Paramedic();
|
|
|
|
|
$model = $model->where("project_id", $bed->project_id);
|
|
|
|
|
$model = $model->where("status", 1);
|
|
|
|
|
if ($request->sex == "女") {
|
|
|
|
|
$model = $model->where("sex", "女");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$page_size = 3;
|
|
|
|
|
$paramedics = $model->limit($page_size)->select("id", "name", "avatar", "sex", "birthday", "hometown")->get();
|
|
|
|
|
return response()->json($paramedics->toArray());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @OA\Get(
|
|
|
|
|
* path="/customer/get-patients",
|
|
|
|
|
@ -194,8 +229,8 @@ class OrdersController extends CommonController
|
|
|
|
|
"productItem",
|
|
|
|
|
"productParamedicLevel",
|
|
|
|
|
"building",
|
|
|
|
|
"bed" => function($query) {
|
|
|
|
|
$query->with(["room","building"]);
|
|
|
|
|
"bed" => function ($query) {
|
|
|
|
|
$query->with(["room", "building"]);
|
|
|
|
|
},
|
|
|
|
|
"paramedic"
|
|
|
|
|
])->paginate(10);
|
|
|
|
|
@ -234,8 +269,8 @@ class OrdersController extends CommonController
|
|
|
|
|
"productItem",
|
|
|
|
|
"productParamedicLevel",
|
|
|
|
|
"paramedicLevel",
|
|
|
|
|
"bed" => function($query) {
|
|
|
|
|
$query->with(["room","building"]);
|
|
|
|
|
"bed" => function ($query) {
|
|
|
|
|
$query->with(["room", "building"]);
|
|
|
|
|
},
|
|
|
|
|
"paramedic"
|
|
|
|
|
])->find($id);
|
|
|
|
|
@ -296,7 +331,7 @@ class OrdersController extends CommonController
|
|
|
|
|
{
|
|
|
|
|
DB::beginTransaction();
|
|
|
|
|
try {
|
|
|
|
|
$has_orders = Orders::where("customer_id",$this->customer->id)->whereIn("status",[Orders::STATUS_UNCONFIRMED,Orders::STATUS_UNASSIGNED,Orders::STATUS_ONGOING])->count();
|
|
|
|
|
$has_orders = Orders::where("customer_id", $this->customer->id)->whereIn("status", [Orders::STATUS_UNCONFIRMED, Orders::STATUS_UNASSIGNED, Orders::STATUS_ONGOING])->count();
|
|
|
|
|
if ($has_orders) {
|
|
|
|
|
return response()->json([
|
|
|
|
|
"errorcode" => "0",
|
|
|
|
|
@ -552,10 +587,10 @@ class OrdersController extends CommonController
|
|
|
|
|
public function getBalances()
|
|
|
|
|
{
|
|
|
|
|
$balances = (new Balance())->with([
|
|
|
|
|
"order" => function($query) {
|
|
|
|
|
$query->select("id","serial");
|
|
|
|
|
"order" => function ($query) {
|
|
|
|
|
$query->select("id", "serial");
|
|
|
|
|
}
|
|
|
|
|
])->select("id","customer_id","money","balance","belongs_type","belongs_id","remark","order_id","created_at")->orderBy("id", "desc")->paginate(10);
|
|
|
|
|
])->select("id", "customer_id", "money", "balance", "belongs_type", "belongs_id", "remark", "order_id", "created_at")->orderBy("id", "desc")->paginate(10);
|
|
|
|
|
return response()->json($balances->toArray());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|