上传押金凭证

This commit is contained in:
yaooo 2023-11-16 13:54:06 +08:00
parent 531531a3e5
commit 089a449f3a

View File

@ -11,6 +11,7 @@
use app\common\logic\RedisLogic;
use app\common\model\auth\Admin;
use app\common\model\Company;
use app\common\model\company\CompanyAccountLog;
use app\common\model\contract\Contract;
use app\common\model\dict\DictData;
use app\common\model\task_scheduling\TaskScheduling;
@ -356,4 +357,62 @@
];
return $this->success('请求成功',$result);
}
public function depositRechargeTransferVoucher()
{
if(!$this->request->isPost()){
return $this->fail('请求方式错误');
}
$param = $this->request->param();
if(empty($param['company_id'])){
return $this->fail('缺少company_id');
}
if(empty($param['deposit'])){
return $this->fail('缺少押金金额');
}
if(empty($param['voucher'])){
return $this->fail('缺少凭证文件');
}
try {
$adminId = 1;
Db::startTrans();
$data = [
'company_id' => $param['company_id'],
'deposit' => $param['deposit'],
'voucher' => $param['voucher'],
'create_admin_id' => $adminId,
'create_time' => time(),
'update_time' => time()
];
$result = (new CompanyDepositVoucher())->save($data);
$companyModel = Company::where(['id' => $param['company_id']])->find();
$left_amount = bcadd($companyModel['deposit'], $param['deposit'], 2);
// 添加流水记录
$datas = [
'sn' => generate_sn(CompanyAccountLog::class, 'sn', 20),
'user_id' => 0,
'company_id' => $param['company_id'],
'change_type' => CompanyAccountLog::COMPANY_DEPOSIT,
'change_object' => CompanyAccountLog::DEPOSIT,
'action' => 1,
'change_amount' => $param['deposit'],
'left_amount' =>$left_amount,
'remark' => '后台押金转账凭证充值',
'status' => 1,
];
CompanyAccountLog::create($datas);
// 更新公司押金金额
$companyModel->deposit = $left_amount;
$companyModel->save();
Db::commit();
return $this->success('成功');
} catch (Exception $exception) {
Db::rollback();
return $this->fail($exception->getMessage());
}
}
}