Cashier.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. namespace app\admin\controller\qingdongams\finance;
  3. use addons\qingdongams\model\Consume;
  4. use addons\qingdongams\model\Consume as ConsumeModel;
  5. use addons\qingdongams\model\ConsumeDetail;
  6. use addons\qingdongams\model\ExamineRecord;
  7. use app\admin\controller\qingdongams\Base;
  8. /**
  9. * 出纳管理
  10. * @icon fa fa-user
  11. */
  12. class Cashier extends Base {
  13. protected $relationSearch = true;
  14. /**
  15. * @var \addons\qingdongams\model\Consume
  16. */
  17. protected $model = null;
  18. public function _initialize() {
  19. parent::_initialize();
  20. $this->model = new Consume();
  21. }
  22. /**
  23. * 查看
  24. */
  25. public function index() {
  26. //设置过滤方法
  27. $this->request->filter(['strip_tags', 'trim']);
  28. if ($this->request->isAjax()) {
  29. //如果发送的来源是Selectpage,则转发到Selectpage
  30. if ($this->request->request('keyField')) {
  31. return $this->selectpage();
  32. }
  33. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  34. $list = $this->model->where($where)->where(['check_status' => 2])->with(['staff','customer'])
  35. ->order('id desc')->paginate($limit);
  36. $result = array("total" => $list->total(), "rows" => $list->items());
  37. return json($result);
  38. }
  39. return $this->view->fetch();
  40. }
  41. //费用详情
  42. public function detail($ids = null) {
  43. // 基本信息
  44. $row = $this->model->where('id',$ids)->with(['staff','customer'])->find();
  45. if(empty($row)){
  46. $this->error('信息不存在');
  47. }
  48. $row['detail']= ConsumeDetail::where(['consume_id'=>$ids])->select();
  49. // 操作记录
  50. $operations = ExamineRecord::where('relation_id',$ids)->with(['checkStaff'])->select();
  51. $this->assign('ids',$ids);
  52. $this->assign('row',$row);
  53. $this->assign('operations',$operations);
  54. return $this->view->fetch();
  55. }
  56. // 回款: 新增合同的回款/列表/详情
  57. // 费用:列表/新增/修改/删除
  58. // 出纳:列表/详情/批量打款 单独打款操作 is_cashier=1
  59. //出纳
  60. public function cashier(){
  61. $ids=input('ids');
  62. if(empty($ids)){
  63. $this->error('参数错误');
  64. }
  65. $ids = rtrim($ids,']');
  66. $ids = ltrim($ids,'[');
  67. $ids=explode(',',$ids);
  68. ConsumeModel::where(['id'=>['in',$ids]])->update(['is_cashier'=>1]);
  69. $data=[];
  70. foreach ($ids as $id){
  71. $data[] = [
  72. 'relation_type' => ExamineRecord::CONSUME_TYPE,
  73. 'relation_id' => $id,
  74. 'check_staff_id' => $this->_staff->id,
  75. 'status' => 1,
  76. 'content' => '出纳审核',
  77. 'createtime' => time(),
  78. 'updatetime' => time()
  79. ];
  80. }
  81. $examineModel=new ExamineRecord();
  82. $examineModel->insertAll($data);
  83. $this->success('操作成功');
  84. }
  85. }