User.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. namespace app\admin\controller\taxi;
  3. use app\api\model\taxi\MotorRecord;
  4. use app\common\controller\AdminController;
  5. use app\common\model\TaxiUser;
  6. use app\http\IResponse;
  7. use think\App;
  8. use think\Exception;
  9. class User extends AdminController
  10. {
  11. protected $model;
  12. public function __construct(App $app = null)
  13. {
  14. parent::__construct($app);
  15. $this->model = new TaxiUser();
  16. }
  17. /**
  18. * @desc 审核司机
  19. * @param $ids
  20. * @throws \think\exception\PDOException
  21. * @author weichuanbao<654745815@qq.com>
  22. * @date 2021/12/7 0007
  23. */
  24. public function check($ids)
  25. {
  26. $row = $this->model::get($ids);
  27. if (!$row) {
  28. IResponse::failure('记录不存在');
  29. }
  30. $result = false;
  31. $this->model->startTrans();
  32. try {
  33. $row->status = 5;
  34. $result = $row->save();
  35. $this->model->commit();
  36. }
  37. catch(Exception $e) {
  38. $this->model->rollback();
  39. }
  40. if ($result) {
  41. IResponse::success([],'成功');
  42. }
  43. IResponse::failure('失败');
  44. }
  45. /**
  46. * @desc 发放合伙资产
  47. * @param $ids
  48. * @throws \think\db\exception\DataNotFoundException
  49. * @throws \think\db\exception\ModelNotFoundException
  50. * @throws \think\exception\DbException
  51. * @throws \think\exception\PDOException
  52. * @author weichuanbao<654745815@qq.com>
  53. * @date 2022/1/7 0007
  54. */
  55. public function partnership($ids)
  56. {
  57. $row = $this->model->with('user')->find($ids);
  58. if (!$row) {
  59. IResponse::failure('记录不存在');
  60. }
  61. $params = input();
  62. $params['amount'] = input('amount', 0);
  63. $MotorRecord = new MotorRecord();
  64. $result = false;
  65. $this->model->startTrans();
  66. try {
  67. $row->user->partnership = $params['amount'];
  68. $result = $row->user->save();
  69. $MotorRecord->setMoneyLog($row['user'], 'partnership', $params['amount'], 30, '发放合伙资产');
  70. $MotorRecord->saveMoneyLog();
  71. $this->model->commit();
  72. }
  73. catch(Exception $e) {
  74. $this->model->rollback();
  75. }
  76. if ($result) {
  77. IResponse::success([],'成功');
  78. }else{
  79. IResponse::failure('失败');
  80. }
  81. }
  82. }