更新
This commit is contained in:
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\adminapi\controller\order;
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\order\OrderLists;
|
||||
use app\adminapi\logic\order\OrderLogic;
|
||||
use app\adminapi\validate\order\OrderValidate;
|
||||
|
||||
/**
|
||||
* 订单管理控制器
|
||||
* Class OrderController
|
||||
* @package app\adminapi\controller\order
|
||||
*/
|
||||
class OrderController extends BaseAdminController
|
||||
{
|
||||
/**
|
||||
* @notes 订单列表
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new OrderLists());
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 订单详情
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new OrderValidate())->post()->goCheck('detail');
|
||||
$detail = OrderLogic::detail($params['id']);
|
||||
|
||||
if (!$detail) {
|
||||
return $this->fail('订单不存在');
|
||||
}
|
||||
|
||||
return $this->data($detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 创建订单
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$params = (new OrderValidate())->post()->goCheck('create');
|
||||
$params['creator_id'] = $this->adminId;
|
||||
|
||||
$result = OrderLogic::create($params);
|
||||
if (!$result) {
|
||||
return $this->fail(OrderLogic::getError());
|
||||
}
|
||||
|
||||
return $this->success('创建成功', $result->toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 编辑订单
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new OrderValidate())->post()->goCheck('edit');
|
||||
|
||||
$result = OrderLogic::edit($params['id'], $params);
|
||||
if (!$result) {
|
||||
return $this->fail(OrderLogic::getError());
|
||||
}
|
||||
|
||||
return $this->success('编辑成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 支付订单
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function pay()
|
||||
{
|
||||
$params = (new OrderValidate())->post()->goCheck('pay');
|
||||
|
||||
$result = OrderLogic::pay($params['id'], $params['payment_method']);
|
||||
if (!$result) {
|
||||
return $this->fail(OrderLogic::getError());
|
||||
}
|
||||
|
||||
return $this->success('支付成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 取消订单
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function cancel()
|
||||
{
|
||||
$params = (new OrderValidate())->post()->goCheck('cancel');
|
||||
|
||||
$result = OrderLogic::cancel($params['id']);
|
||||
if (!$result) {
|
||||
return $this->fail(OrderLogic::getError());
|
||||
}
|
||||
|
||||
return $this->success('取消成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 退款订单
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function refund()
|
||||
{
|
||||
$params = (new OrderValidate())->post()->goCheck('refund');
|
||||
|
||||
$result = OrderLogic::refund($params['id']);
|
||||
if (!$result) {
|
||||
return $this->fail(OrderLogic::getError());
|
||||
}
|
||||
|
||||
return $this->success('退款成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 删除订单
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new OrderValidate())->post()->goCheck('delete');
|
||||
|
||||
$result = OrderLogic::delete($params['id']);
|
||||
if (!$result) {
|
||||
return $this->fail(OrderLogic::getError());
|
||||
}
|
||||
|
||||
return $this->success('删除成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 导出订单
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function export()
|
||||
{
|
||||
return $this->dataLists(new OrderLists());
|
||||
}
|
||||
}
|
||||
@@ -283,4 +283,38 @@ class DiagnosisController extends BaseAdminController
|
||||
$result = DiagnosisLogic::generateMiniProgramQrcode($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 搜索患者(用于创建订单等场景)
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function searchPatient()
|
||||
{
|
||||
$keyword = $this->request->get('keyword', '');
|
||||
$page_no = $this->request->get('page_no', 1);
|
||||
$page_size = $this->request->get('page_size', 10);
|
||||
|
||||
if (empty($keyword)) {
|
||||
return $this->success('', ['lists' => [], 'count' => 0]);
|
||||
}
|
||||
|
||||
$offset = ($page_no - 1) * $page_size;
|
||||
|
||||
$lists = \app\common\model\tcm\Diagnosis::where('patient_name|patient_phone|patient_id_card', 'like', '%' . $keyword . '%')
|
||||
->field(['id', 'patient_name', 'patient_phone', 'patient_id_card', 'gender', 'age'])
|
||||
->limit($offset, $page_size)
|
||||
->order('id desc')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$count = \app\common\model\tcm\Diagnosis::where('patient_name|patient_phone|patient_id_card', 'like', '%' . $keyword . '%')
|
||||
->count();
|
||||
|
||||
return $this->success('', [
|
||||
'lists' => $lists,
|
||||
'count' => $count,
|
||||
'page_no' => $page_no,
|
||||
'page_size' => $page_size
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,4 +83,38 @@ class UserController extends BaseAdminController
|
||||
return $this->fail($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 搜索用户(用于创建订单等场景)
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function search()
|
||||
{
|
||||
$keyword = $this->request->get('keyword', '');
|
||||
$page_no = $this->request->get('page_no', 1);
|
||||
$page_size = $this->request->get('page_size', 10);
|
||||
|
||||
if (empty($keyword)) {
|
||||
return $this->success('', ['lists' => [], 'count' => 0]);
|
||||
}
|
||||
|
||||
$offset = ($page_no - 1) * $page_size;
|
||||
|
||||
$lists = \app\common\model\user\User::where('nickname|mobile|account', 'like', '%' . $keyword . '%')
|
||||
->field(['id', 'nickname', 'mobile', 'account', 'avatar'])
|
||||
->limit($offset, $page_size)
|
||||
->order('id desc')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$count = \app\common\model\user\User::where('nickname|mobile|account', 'like', '%' . $keyword . '%')
|
||||
->count();
|
||||
|
||||
return $this->success('', [
|
||||
'lists' => $lists,
|
||||
'count' => $count,
|
||||
'page_no' => $page_no,
|
||||
'page_size' => $page_size
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user