142 lines
5.2 KiB
PHP
142 lines
5.2 KiB
PHP
<?php
|
||
// +----------------------------------------------------------------------
|
||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||
// +----------------------------------------------------------------------
|
||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||
// | 开源版本可自由商用,可去除界面版权logo
|
||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||
// | 访问官网:https://www.likeadmin.cn
|
||
// | likeadmin团队 版权所有 拥有最终解释权
|
||
// +----------------------------------------------------------------------
|
||
// | author: likeadminTeam
|
||
// +----------------------------------------------------------------------
|
||
|
||
namespace app\adminapi\logic\bid;
|
||
|
||
|
||
use app\common\model\bid\BidBiddingDecision;
|
||
use app\common\model\bid\BidSecurityApply;
|
||
use app\common\model\project\Project;
|
||
use app\common\model\custom\Custom;
|
||
use app\common\logic\BaseLogic;
|
||
use think\facade\Db;
|
||
|
||
|
||
/**
|
||
* BidSecurityApply逻辑
|
||
* Class BidSecurityApplyLogic
|
||
* @package app\adminapi\logic\bid
|
||
*/
|
||
class BidSecurityApplyLogic extends BaseLogic
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 添加
|
||
* @param array $params
|
||
* @return bool
|
||
* @author likeadmin
|
||
* @date 2023/12/16 10:46
|
||
*/
|
||
public static function add(array $params): bool
|
||
{
|
||
$bidding_decision = BidBiddingDecision::field('project_id')->where('id',$params['bidding_decision_id'])->findOrEmpty();
|
||
Db::startTrans();
|
||
try {
|
||
BidSecurityApply::create([
|
||
'security_apply_code' => data_unique_code('投标保证金'),
|
||
'project_id' => $bidding_decision['project_id'],
|
||
'bidding_decision_id' => $params['bidding_decision_id'],
|
||
'applier' => $params['applier'],
|
||
'pay_type' => $params['pay_type'],
|
||
'refund_date' => !empty($params['refund_date']) ? strtotime($params['refund_date']) : 0,
|
||
'remark' => $params['remark'] ?? '',
|
||
'annex' => $params['annex']? json_encode($params['annex']) : null,
|
||
'deposit_bank' => $params['deposit_bank'],
|
||
'account_name' => $params['account_name'],
|
||
'account' => $params['account'],
|
||
]);
|
||
Db::commit();
|
||
return true;
|
||
} catch (\Exception $e) {
|
||
Db::rollback();
|
||
self::setError($e->getMessage());
|
||
return false;
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 编辑
|
||
* @param array $params
|
||
* @return bool
|
||
* @author likeadmin
|
||
* @date 2023/12/16 10:46
|
||
*/
|
||
public static function edit(array $params): bool
|
||
{
|
||
$bidding_decision = BidBiddingDecision::field('project_id')->where('id',$params['bidding_decision_id'])->findOrEmpty();
|
||
Db::startTrans();
|
||
try {
|
||
BidSecurityApply::where('id', $params['id'])->update([
|
||
'security_apply_code' => data_unique_code('投标保证金'),
|
||
'project_id' => $bidding_decision['project_id'],
|
||
'bidding_decision_id' => $params['bidding_decision_id'],
|
||
'applier' => $params['applier'],
|
||
'pay_type' => $params['pay_type'],
|
||
'refund_date' => !empty($params['refund_date']) ? strtotime($params['refund_date']) : 0,
|
||
'remark' => $params['remark'] ?? '',
|
||
'annex' => $params['annex']? json_encode($params['annex']) : null,
|
||
'deposit_bank' => $params['deposit_bank'],
|
||
'account_name' => $params['account_name'],
|
||
'account' => $params['account'],
|
||
]);
|
||
Db::commit();
|
||
return true;
|
||
} catch (\Exception $e) {
|
||
Db::rollback();
|
||
self::setError($e->getMessage());
|
||
return false;
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 删除
|
||
* @param array $params
|
||
* @return bool
|
||
* @author likeadmin
|
||
* @date 2023/12/16 10:46
|
||
*/
|
||
public static function delete(array $params): bool
|
||
{
|
||
return BidSecurityApply::destroy($params['id']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取详情
|
||
* @param $params
|
||
* @return array
|
||
* @author likeadmin
|
||
* @date 2023/12/16 10:46
|
||
*/
|
||
public static function detail($params): array
|
||
{
|
||
$data = BidSecurityApply::field('id,security_apply_code,project_id,bidding_decision_id,applier,pay_type,refund_date,remark,annex,deposit_bank,account_name,account')
|
||
->findOrEmpty($params['id']);
|
||
$bidding_decision = BidBiddingDecision::field('code,margin_amount,bidding_time')->where('id',$data['bidding_decision_id'])->findOrEmpty();
|
||
$project = Project::field('custom_id,name,project_code')->where('id',$data['project_id'])->findOrEmpty();
|
||
$custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty();
|
||
$data['bidding_decision_code'] = $bidding_decision['code'];
|
||
$data['project_name'] = $project['name'];
|
||
$data['project_code'] = $project['project_code'];
|
||
$data['custom_name'] = $custom['name'];
|
||
$data['pay_type_text'] = $data->pay_type_text;
|
||
$data['margin_amount'] = $bidding_decision['margin_amount'];
|
||
$data['bidding_time'] = $bidding_decision['bidding_time'];
|
||
$data['payment_account_info'] = [];
|
||
return $data->toArray();
|
||
}
|
||
} |