| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- <?php
- namespace app\admin\controller\taxi;
- use app\api\model\taxi\MotorRecord;
- use app\common\controller\AdminController;
- use app\common\model\TaxiUser;
- use app\http\IResponse;
- use think\App;
- use think\Exception;
- class User extends AdminController
- {
- protected $model;
- public function __construct(App $app = null)
- {
- parent::__construct($app);
- $this->model = new TaxiUser();
- }
- /**
- * @desc 审核司机
- * @param $ids
- * @throws \think\exception\PDOException
- * @author weichuanbao<654745815@qq.com>
- * @date 2021/12/7 0007
- */
- public function check($ids)
- {
-
- $row = $this->model::get($ids);
- if (!$row) {
- IResponse::failure('记录不存在');
- }
- if(!$row['user_id'] || !model('common/users')->where(['id'=> $row['user_id']])->find()){
- IResponse::failure('未绑定用户账号');
- }
- $result = false;
- $this->model->startTrans();
- try {
- $row->status = 5;
- $result = $row->save();
- $this->model->commit();
- }
- catch(Exception $e) {
- $this->model->rollback();
- }
- if ($result) {
- IResponse::success([],'成功');
- }
- IResponse::failure('失败');
- }
-
- /**
- * @desc 发放合伙资产
- * @param $ids
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- * @throws \think\exception\PDOException
- * @author weichuanbao<654745815@qq.com>
- * @date 2022/1/7 0007
- */
-
- public function partnership($ids)
- {
- $row = $this->model->with('user')->find($ids);
-
- if (!$row) {
- IResponse::failure('记录不存在');
- }
- $params = input();
- $params['amount'] = input('amount', 0);
- if(floatval($params['amount'])<=0){
- IResponse::failure('请输入合法资产金额');
- }
- $MotorRecord = new MotorRecord();
- $result = false;
- $this->model->startTrans();
- var_dump($row->user);
- try {
- if(!$row->user){
- IResponse::failure('该司机未绑定用户');
- }
- $row->user->partnership = $params['amount'];
- $result = $row->user->save();
- IResponse::failure('该司机未绑定用户');
- $MotorRecord->setMoneyLog($row['user'], 'partnership', $params['amount'], 30, '发放合伙资产');
- $MotorRecord->saveMoneyLog();
- $this->model->commit();
- }
- catch(Exception $e) {
- $this->model->rollback();
- IResponse::failure($e->getMessage());
- }
- if ($result) {
- IResponse::success([],'成功');
- }else{
- IResponse::failure('失败');
- }
-
- }
- }
|