add:押金充值线上转账对公账户临时方案
This commit is contained in:
parent
133e14c9eb
commit
22ed2105fb
@ -18,6 +18,7 @@ namespace app\adminapi\controller;
|
|||||||
|
|
||||||
use app\adminapi\lists\CompanyLists;
|
use app\adminapi\lists\CompanyLists;
|
||||||
use app\adminapi\logic\auth\AdminLogic;
|
use app\adminapi\logic\auth\AdminLogic;
|
||||||
|
use app\common\enum\PayEnum;
|
||||||
use app\common\logic\CompanyLogic;
|
use app\common\logic\CompanyLogic;
|
||||||
use app\adminapi\validate\CompanyValidate;
|
use app\adminapi\validate\CompanyValidate;
|
||||||
use app\api\controller\JunziqianController;
|
use app\api\controller\JunziqianController;
|
||||||
@ -25,6 +26,10 @@ use app\common\logic\RedisLogic;
|
|||||||
use app\common\model\Approve;
|
use app\common\model\Approve;
|
||||||
use app\common\model\auth\Admin;
|
use app\common\model\auth\Admin;
|
||||||
use app\common\model\Company;
|
use app\common\model\Company;
|
||||||
|
use app\common\model\company\CompanyAccountLog;
|
||||||
|
use app\common\model\CompanyDepositVoucher;
|
||||||
|
use app\common\model\recharge\RechargeOrder;
|
||||||
|
use app\common\model\user\UserAccountLog;
|
||||||
use think\Exception;
|
use think\Exception;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
use app\common\logic\contract\ContractLogic;
|
use app\common\logic\contract\ContractLogic;
|
||||||
@ -473,4 +478,49 @@ class CompanyController extends BaseAdminController
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 押金凭证录入,并将押金写入公司押金账户,新增一条押金充值流水
|
||||||
|
public function depositRechargeTransferVoucher()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$param = $this->request->param();
|
||||||
|
Db::startTrans();
|
||||||
|
$data = [
|
||||||
|
'company_id' => $param['company_id'],
|
||||||
|
'deposit' => $param['deposit'],
|
||||||
|
'voucher' => $param['voucher'],
|
||||||
|
'create_admin_id' => $this->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' => 300,
|
||||||
|
'change_object' => 2,
|
||||||
|
'action' => 1,
|
||||||
|
'change_amount' => $param['deposit'],
|
||||||
|
'left_amount' =>$left_amount,
|
||||||
|
'remark' => '后台押金转账凭证充值',
|
||||||
|
];
|
||||||
|
CompanyAccountLog::create($datas);
|
||||||
|
|
||||||
|
// 更新公司押金金额
|
||||||
|
$companyModel->deposit = $left_amount;
|
||||||
|
$companyModel->save();
|
||||||
|
Db::commit();
|
||||||
|
return $this->success('成功');
|
||||||
|
} catch (Exception $exception) {
|
||||||
|
Db::rollback();
|
||||||
|
return $this->fail($exception->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -360,4 +360,18 @@ class CompanyController extends BaseApiController
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询签约的甲方公司
|
||||||
|
*/
|
||||||
|
public function getPartyACompany()
|
||||||
|
{
|
||||||
|
$company = Company::where(['id'=>$this->userInfo['company_id']])->find();
|
||||||
|
$contract = Contract::where(['party_b'=>$company['id']])->find();
|
||||||
|
if ($contract) {
|
||||||
|
$partyA = Company::where(['id'=>$contract['party_a']])->find();
|
||||||
|
return $this->success('ok', $partyA);
|
||||||
|
}
|
||||||
|
return $this->fail('当前公司未签约甲方公司');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
$company=Company::where('user_id',$order['user_id'])->find();
|
$company=Company::where('user_id',$order['user_id'])->find();
|
||||||
$left_amount= $company['deposit']+$order->order_amount;
|
$left_amount= $company['deposit']+$order->order_amount;
|
||||||
$datas = [
|
$datas = [
|
||||||
'order_sn' => $order->sn,
|
'sn' => $order->sn,
|
||||||
'user_id' => $order->user_id,
|
'user_id' => $order->user_id,
|
||||||
'company_id' => $company['id']??0,
|
'company_id' => $company['id']??0,
|
||||||
'change_type' => 300,
|
'change_type' => 300,
|
||||||
@ -86,7 +86,7 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
'action' => 1,
|
'action' => 1,
|
||||||
'change_amount' => $order->order_amount,
|
'change_amount' => $order->order_amount,
|
||||||
'left_amount' =>$left_amount,
|
'left_amount' =>$left_amount,
|
||||||
'remark' => '保证金充值',
|
'remark' => '押金充值',
|
||||||
];
|
];
|
||||||
CompanyAccountLog::create($datas);
|
CompanyAccountLog::create($datas);
|
||||||
Company::where('id',$company['id'])->update(['deposit'=>$left_amount]);
|
Company::where('id',$company['id'])->update(['deposit'=>$left_amount]);
|
||||||
|
@ -63,7 +63,7 @@ class WithdrawLogic extends BaseLogic
|
|||||||
|
|
||||||
// 1.扣除公司账户余额
|
// 1.扣除公司账户余额
|
||||||
$amount = $withDrawInfo['amount']; // 提现金额
|
$amount = $withDrawInfo['amount']; // 提现金额
|
||||||
$leftMoney = bcsub($companyInfo['company_money'], $amount); // 提现后剩余金额
|
$leftMoney = bcsub($companyInfo['company_money'], $amount, 2); // 提现后剩余金额
|
||||||
if ($leftMoney < 0) {
|
if ($leftMoney < 0) {
|
||||||
throw new Exception('公司账户余额不足');
|
throw new Exception('公司账户余额不足');
|
||||||
}
|
}
|
||||||
@ -90,7 +90,7 @@ class WithdrawLogic extends BaseLogic
|
|||||||
$tempUserLeftMoney = 0;
|
$tempUserLeftMoney = 0;
|
||||||
// 本次提现周期内增加的金额总和 周期内用户状态已完成的 变动类型为任务收益金额增加 动作为增加 未提现状态 的变动金额之和
|
// 本次提现周期内增加的金额总和 周期内用户状态已完成的 变动类型为任务收益金额增加 动作为增加 未提现状态 的变动金额之和
|
||||||
$tempUserMoneySycleTotal = UserAccountLog::where(['user_id'=>$user->id, 'status'=>1, 'action'=>1, 'change_type'=>202, 'is_withdraw'=>0])->where('create_time','<', $endCycle)->sum('change_amount');
|
$tempUserMoneySycleTotal = UserAccountLog::where(['user_id'=>$user->id, 'status'=>1, 'action'=>1, 'change_type'=>202, 'is_withdraw'=>0])->where('create_time','<', $endCycle)->sum('change_amount');
|
||||||
$tempUserLeftMoney = bcsub($user->user_money,$tempUserMoneySycleTotal);
|
$tempUserLeftMoney = bcsub($user->user_money,$tempUserMoneySycleTotal, 2);
|
||||||
if( $tempUserLeftMoney < 0 ){
|
if( $tempUserLeftMoney < 0 ){
|
||||||
throw new Exception('账户异常,用户余额不足,user_id:'.$user->id.",扣除金额:".$tempUserMoneySycleTotal);
|
throw new Exception('账户异常,用户余额不足,user_id:'.$user->id.",扣除金额:".$tempUserMoneySycleTotal);
|
||||||
}
|
}
|
||||||
|
8
app/common/model/CompanyDepositVoucher.php
Normal file
8
app/common/model/CompanyDepositVoucher.php
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\model;
|
||||||
|
|
||||||
|
class CompanyDepositVoucher extends BaseModel
|
||||||
|
{
|
||||||
|
protected $name = 'company_deposit_voucher';
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user