PhOrders.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. namespace app\api\controller\v1;
  3. use app\api\controller\Base;
  4. use app\common\model\Worker;
  5. use app\hander\HelpHander;
  6. use think\App;
  7. use think\Db;
  8. use think\exception\Handle;
  9. class PhOrders extends Base
  10. {
  11. //护工工单列表
  12. public function todoList(){
  13. $page = input('page',1);
  14. $size = input('size',10);
  15. $status = input('status/d',-1);
  16. $model = new \app\common\model\PhOrders();
  17. $res = $model->workerOrderList($this->orgId,$status,$page,$size,$this->userId);
  18. HelpHander::success($res,'操作成功');
  19. }
  20. //护工工单详情
  21. public function todoDetail(){
  22. $id = input('id',0);
  23. $model = new \app\common\model\PhOrders();
  24. $res = $model->todoDetail($id);
  25. HelpHander::success($res,'操作成功');
  26. }
  27. //调度订单列表
  28. public function orderList(){
  29. $page = input('page',1);
  30. $size = input('size',10);
  31. $status = input('status/d',-1);
  32. $model = new \app\common\model\PhOrders();
  33. $res = $model->orderList1($this->orgId,$status,$page,$size);
  34. HelpHander::success($res,'操作成功');
  35. }
  36. //订单详情
  37. public function detail(){
  38. $id = input('id/d','');
  39. $model = new \app\common\model\PhOrders();
  40. $ret = $model->getInfo($id);
  41. HelpHander::success($ret,'操作成功');
  42. }
  43. //取消订单
  44. public function cancel(){
  45. $note = input('cancelReason','','trim');
  46. $id = input('id/d',0);
  47. $model = new \app\common\model\PhOrders();
  48. $ret = $model->cancelOrder($id,$note,$this->userId);
  49. if(!$ret){
  50. HelpHander::error($model->getError());
  51. }else{
  52. HelpHander::success([],'操作成功');
  53. }
  54. }
  55. //确认完成
  56. public function finish(){
  57. $model = new \app\common\model\PhOrders();
  58. $res = $model->finishSave($this->userId,$this->orgId);
  59. if($res){
  60. HelpHander::success([],'操作成功');
  61. }else{
  62. HelpHander::error($model->getError());
  63. }
  64. }
  65. //发单
  66. public function add(){
  67. $model = new \app\common\model\PhOrders();
  68. $res = $model->addSave($this->userId,$this->orgId,1);
  69. if($res){
  70. HelpHander::success([],'操作成功');
  71. }else{
  72. HelpHander::error($model->getError());
  73. }
  74. }
  75. public function send(){
  76. $model = new \app\common\model\PhOrders();
  77. $res = $model->sendSave($this->userId,$this->orgId);
  78. if($res){
  79. HelpHander::success([],'操作成功');
  80. }else{
  81. HelpHander::error($model->getError());
  82. }
  83. }
  84. public function getWorkerAll(){
  85. $model = new Worker();
  86. $ret = $model->getAllByOrg($this->orgId);
  87. HelpHander::success($ret,'成功');
  88. }
  89. public function payOrder(){
  90. $id = input('id/d',0);
  91. $remark = input('remark','','trim');
  92. $money = input('money/f',0);
  93. if($money <= 0){
  94. HelpHander::error('输入金额错误');
  95. }
  96. $res = model('PhOrderPay')->addSaveDispatch($this->orgId,$id,$money,$remark);
  97. if($res){
  98. HelpHander::success([],'操作成功');
  99. }else{
  100. HelpHander::error(model('PhOrderPay')->getError());
  101. }
  102. }
  103. /**
  104. * 退款
  105. */
  106. public function refund(){
  107. $res = model('PhOrderPay')->refundOrder($this->userId);
  108. if($res){
  109. HelpHander::success([],'操作成功');
  110. }else{
  111. HelpHander::error(model('PhOrderPay')->getError());
  112. }
  113. }
  114. public function payInfo(){
  115. $id = input('id/d',0);
  116. $pay = Db::name('ph_order_pay')->where('id',$id)->find();
  117. if(!$pay){
  118. HelpHander::error('记录不存在');
  119. }
  120. HelpHander::success($pay,'成功');
  121. }
  122. }