InvoiceInfo.php 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?php
  2. /**
  3. * 发票开户行控制器
  4. *
  5. * @author qifan
  6. * @date 2020-12-19
  7. */
  8. namespace app\crm\controller;
  9. use app\admin\controller\ApiCommon;
  10. use app\crm\model\InvoiceInfoLogic;
  11. use think\Hook;
  12. use think\Request;
  13. class InvoiceInfo extends ApiCommon
  14. {
  15. /**
  16. * 用于判断权限
  17. * @permission 无限制
  18. * @allow 登录用户可访问
  19. * @other 其他根据系统设置
  20. **/
  21. public function _initialize()
  22. {
  23. $action = [
  24. 'permission' => [],
  25. 'allow' => ['index', 'read', 'save', 'update', 'delete']
  26. ];
  27. Hook::listen('check_auth',$action);
  28. $request = Request::instance();
  29. $a = strtolower($request->action());
  30. if (!in_array($a, $action['permission'])) {
  31. parent::_initialize();
  32. } else {
  33. $param = Request::instance()->param();
  34. $this->param = $param;
  35. }
  36. }
  37. /**
  38. * 列表
  39. *
  40. * @param InvoiceInfoLogic $invoiceInfoLogic
  41. * @return \think\response\Json
  42. * @throws \think\db\exception\DataNotFoundException
  43. * @throws \think\db\exception\ModelNotFoundException
  44. * @throws \think\exception\DbException
  45. */
  46. public function index(InvoiceInfoLogic $invoiceInfoLogic)
  47. {
  48. $data = $invoiceInfoLogic->index($this->param);
  49. return resultArray(['data' => $data]);
  50. }
  51. /**
  52. * 详情
  53. *
  54. * @param InvoiceInfoLogic $invoiceInfoLogic
  55. * @return \think\response\Json
  56. * @throws \think\db\exception\DataNotFoundException
  57. * @throws \think\db\exception\ModelNotFoundException
  58. * @throws \think\exception\DbException
  59. */
  60. public function read(InvoiceInfoLogic $invoiceInfoLogic)
  61. {
  62. if (empty($this->param['info_id'])) return resultArray(['error' => '参数错误']);
  63. $data = $invoiceInfoLogic->read($this->param['info_id']);
  64. return resultArray(['data' => $data]);
  65. }
  66. /**
  67. * 创建
  68. *
  69. * @param InvoiceInfoLogic $invoiceInfoLogic
  70. * @return \think\response\Json
  71. */
  72. public function save(InvoiceInfoLogic $invoiceInfoLogic)
  73. {
  74. if (empty($this->param['customer_id'])) return resultArray(['error' => '请选择客户!']);
  75. $param = $this->param;
  76. $userInfo = $this->userInfo;
  77. $param['user_id'] = $userInfo['id'];
  78. if (!$invoiceInfoLogic->save($param)) return resultArray(['error' => '操作失败!']);
  79. return resultArray(['data' => '操作成功!']);
  80. }
  81. /**
  82. * 编辑
  83. *
  84. * @param InvoiceInfoLogic $invoiceInfoLogic
  85. * @return \think\response\Json
  86. * @throws \think\Exception
  87. * @throws \think\exception\PDOException
  88. */
  89. public function update(InvoiceInfoLogic $invoiceInfoLogic)
  90. {
  91. if (empty($this->param['info_id'])) return resultArray(['error' => '参数错误!']);
  92. if (!$invoiceInfoLogic->update($this->param)) return resultArray(['error' => '操作失败!']);
  93. return resultArray(['data' => '操作成功!']);
  94. }
  95. /**
  96. * 删除
  97. *
  98. * @param InvoiceInfoLogic $invoiceInfoLogic
  99. * @return \think\response\Json
  100. * @throws \think\Exception
  101. * @throws \think\exception\PDOException
  102. */
  103. public function delete(InvoiceInfoLogic $invoiceInfoLogic)
  104. {
  105. if (empty($this->param['info_id'])) return resultArray(['error' => '参数错误!']);
  106. if (!$invoiceInfoLogic->delete($this->param['info_id'])) return resultArray(['error' => '操作失败!']);
  107. return resultArray(['data' => '操作成功!']);
  108. }
  109. }