123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- <?php
- namespace app\api\controller\v1;
- use app\api\controller\Base;
- use app\common\model\Worker;
- use app\hander\HelpHander;
- use think\App;
- use think\Db;
- use think\exception\Handle;
- class PhOrders extends Base
- {
- //护工工单列表
- public function todoList(){
- $page = input('page',1);
- $size = input('size',10);
- $status = input('status/d',-1);
- $model = new \app\common\model\PhOrders();
- $res = $model->workerOrderList($this->orgId,$status,$page,$size,$this->userId);
- HelpHander::success($res,'操作成功');
- }
- //护工工单详情
- public function todoDetail(){
- $id = input('id',0);
- $model = new \app\common\model\PhOrders();
- $res = $model->todoDetail($id);
- HelpHander::success($res,'操作成功');
- }
- //调度订单列表
- public function orderList(){
- $page = input('page',1);
- $size = input('size',10);
- $status = input('status/d',-1);
- $model = new \app\common\model\PhOrders();
- $res = $model->orderList1($this->orgId,$this->userId,$status,$page,$size);
- HelpHander::success($res,'操作成功');
- }
- //订单详情
- public function detail(){
- $id = input('id/d','');
- $model = new \app\common\model\PhOrders();
- $ret = $model->getInfo($id,$this->orgId);
- HelpHander::success($ret,'操作成功');
- }
- //取消订单
- public function cancel(){
- $note = input('cancelReason','','trim');
- $id = input('id/d',0);
- $model = new \app\common\model\PhOrders();
- $ret = $model->cancelOrder($id,$note,$this->userId);
- if(!$ret){
- HelpHander::error($model->getError());
- }else{
- HelpHander::success([],'操作成功');
- }
- }
- //确认完成
- public function finish(){
- $model = new \app\common\model\PhOrders();
- $res = $model->finishSave($this->userId,$this->orgId);
- if($res){
- HelpHander::success([],'操作成功');
- }else{
- HelpHander::error($model->getError());
- }
- }
- //发单
- public function add(){
- $model = new \app\common\model\PhOrders();
- $res = $model->addSave($this->userId,$this->orgId,1);
- if($res){
- HelpHander::success([],'操作成功');
- }else{
- HelpHander::error($model->getError());
- }
- }
- public function send(){
- $model = new \app\common\model\PhOrders();
- $res = $model->sendSave($this->userId,$this->orgId);
- if($res){
- HelpHander::success([],'操作成功');
- }else{
- HelpHander::error($model->getError());
- }
- }
- public function getWorkerAll(){
- $model = new Worker();
- $ret = $model->getAllByOrg($this->orgId);
- HelpHander::success($ret,'成功');
- }
- public function payOrder(){
- $id = input('id/d',0);
- $remark = input('remark','','trim');
- $money = input('money/f',0);
- $busType = input('busType/d',0);
- if($money <= 0){
- HelpHander::error('输入金额错误');
- }
- $res = model('PhOrderPay')->addSaveDispatch($this->orgId,$id,$money,$remark,$busType);
- if($res){
- HelpHander::success([],'操作成功');
- }else{
- HelpHander::error(model('PhOrderPay')->getError());
- }
- }
- /**
- * 退款
- */
- public function refund(){
- $res = model('PhOrderPay')->refundOrder($this->userId);
- if($res){
- HelpHander::success([],'操作成功');
- }else{
- HelpHander::error(model('PhOrderPay')->getError());
- }
- }
- public function payInfo(){
- $id = input('id/d',0);
- $pay = Db::name('ph_order_pay')->where('id',$id)->find();
- if(!$pay){
- HelpHander::error('记录不存在');
- }
- HelpHander::success($pay,'成功');
- }
- //护工签名
- public function workerSign(){
- $todoId = input('id/d',0);
- $sign = input('img','');
- if(!$sign){
- HelpHander::error('未上传签名图');
- }
- $res = Db::name('ph_todo')
- ->where('id',$todoId)
- ->update([
- 'sign'=>$sign
- ]);
- if(!$res){
- HelpHander::error('上传失败');
- }
- HelpHander::success([],'上传成功');
- }
- //员工余额记录
- public function balanceRecord()
- {
- $page = input('page',1);
- $size = input('size',10);
- $id = Db::name('worker')
- ->where('user_id',$this->userId)
- ->value('id');
- $list = Db::name('worker_balance')
- ->where('org_id', $this->orgId)
- ->where('worker_id', $id)
- ->order('id', 'desc')
- ->limit(($page-1)*$size,$size)
- ->select();
- foreach ($list as $k => $v) {
- $list[$k]['userName'] = Db::name('user')
- ->where('id', $v['user_id'])
- ->value('real_name');
- if ($v['type'] == 1) {
- $list[$k]['type'] = '订单结算';
- }else if ($v['type'] == 2) {
- $list[$k]['type'] = '工资结算';
- }else if ($v['type'] == 3) {
- $list[$k]['type'] = '管理员增加';
- }else{
- $list[$k]['type'] = '管理员减少';
- }
- }
- HelpHander::success($list);
- }
- }
|