Merge pull request 'update' (#153) from zhangwei into dev

Reviewed-on: #153
This commit is contained in:
weiz 2024-01-11 15:43:48 +08:00
commit 542e8982d2
15 changed files with 306 additions and 191 deletions

View File

@ -18,6 +18,8 @@ namespace app\adminapi\lists\bank;
use app\adminapi\lists\BaseAdminDataLists; use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\bank\BankAccount; use app\common\model\bank\BankAccount;
use app\common\lists\ListsSearchInterface; use app\common\lists\ListsSearchInterface;
use app\common\model\dept\Dept;
use app\common\model\dept\Orgs;
/** /**
@ -38,7 +40,8 @@ class BankAccountLists extends BaseAdminDataLists implements ListsSearchInterfac
public function setSearch(): array public function setSearch(): array
{ {
return [ return [
'=' => ['org_id', 'dept_id', 'account_sn', 'account'], '=' => ['org_id', 'dept_id'],
'%like%' => ['account_sn', 'account','deposit_bank','account_name']
]; ];
} }
@ -55,10 +58,16 @@ class BankAccountLists extends BaseAdminDataLists implements ListsSearchInterfac
public function lists(): array public function lists(): array
{ {
return BankAccount::where($this->searchWhere) return BankAccount::where($this->searchWhere)
->field(['id', 'org_id', 'dept_id', 'account_sn', 'deposit_bank', 'account_name', 'account', 'account_opening_date', 'opening_amount', 'remark']) ->field('id,org_id,dept_id,account_sn,deposit_bank,account_name,account,account_opening_date,opening_amount,remark')
->limit($this->limitOffset, $this->limitLength) ->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc']) ->order(['id' => 'desc'])
->select() ->select()->each(function($data){
$org = Orgs::field('name')->where('id',$data['org_id'])->findOrEmpty();
$dept = Dept::field('name')->where('id',$data['dept_id'])->findOrEmpty();
$data['org_name'] = $org['name'];
$data['dept_name'] = $dept['name'];
return $data;
})
->toArray(); ->toArray();
} }

View File

@ -16,8 +16,12 @@ namespace app\adminapi\lists\bid;
use app\adminapi\lists\BaseAdminDataLists; use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\bid\BidBiddingDecision;
use app\common\model\bid\BidSecurityApply; use app\common\model\bid\BidSecurityApply;
use app\common\lists\ListsSearchInterface; use app\common\lists\ListsSearchInterface;
use app\common\model\bid\BidSecurityRefund;
use app\common\model\custom\Custom;
use app\common\model\project\Project;
use think\facade\Db; use think\facade\Db;
/** /**
@ -38,7 +42,8 @@ class BidSecurityApplyLists extends BaseAdminDataLists implements ListsSearchInt
public function setSearch(): array public function setSearch(): array
{ {
return [ return [
'=' => ['bsa.bidding_decision_id', 'bsa.applier', 'bsa.pay_type'], '=' => ['bidding_decision_id', 'project_id', 'pay_type'],
'%like%' => ['applier']
]; ];
} }
@ -54,22 +59,26 @@ class BidSecurityApplyLists extends BaseAdminDataLists implements ListsSearchInt
*/ */
public function lists(): array public function lists(): array
{ {
return Db::name('BidSecurityApply')->alias('bsa') return BidSecurityApply::where($this->searchWhere)
->where($this->searchWhere) ->field('id,security_apply_code,project_id,bidding_decision_id,applier,refund_date,create_time')
->whereNull('bsa.delete_time')
->leftJoin('bid_bidding_decision bbd','bbd.id = bsa.bidding_decision_id')
->leftJoin('project p','p.id = bbd.project_id')
->leftJoin('custom ct','ct.id = p.custom_id')
->field('bsa.*, bbd.project_id, bbd.bidding_time, bbd.margin_amount, p.name as project_name, p.project_code, ct.name as customer_name')
->limit($this->limitOffset, $this->limitLength) ->limit($this->limitOffset, $this->limitLength)
->order(['bsa.id' => 'desc']) ->order(['id' => 'desc'])
->select()->each(function($item, $key){ ->select()->each(function($data){
//关联数据后续添加 $bidding_decision = BidBiddingDecision::field('code,margin_amount,bidding_time')->where('id',$data['bidding_decision_id'])->findOrEmpty();
$item['approve_no'] = '付款单号'; $project = Project::field('custom_id,name,project_code')->where('id',$data['project_id'])->findOrEmpty();
$item['approve_step'] = '流程步骤'; $custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty();
$item['approve_settle_status'] = 1; $data['bidding_decision_cod'] = $bidding_decision['code'];
$item['bidding_time'] = empty($item['bidding_time']) ? '' : date('Y-m-d H:i:s', $item['bidding_time']); $data['project_name'] = $project['name'];
return $item; $data['project_code'] = $project['project_code'];
$data['custom_name'] = $custom['name'];
$data['bidding_time'] = $bidding_decision['bidding_time'];
//保证金金额
$data['margin_amount'] = $bidding_decision['margin_amount'];
//已退金额
$data['has_refund_amount'] = BidSecurityRefund::where('bid_security_apply_id',$data['id'])->sum('refund_amount');
//未退金额
$data['not_refund_amount'] = $data['margin_amount'] - $data['has_refund_amount'];
return $data;
}) })
->toArray(); ->toArray();
} }
@ -83,12 +92,7 @@ class BidSecurityApplyLists extends BaseAdminDataLists implements ListsSearchInt
*/ */
public function count(): int public function count(): int
{ {
return Db::name('BidSecurityApply')->alias('bsa') return BidSecurityApply::where($this->searchWhere)->count();
->where($this->searchWhere)
->whereNull('bsa.delete_time')
->leftJoin('bid_bidding_decision bbd','bbd.id = bsa.bidding_decision_id')
->leftJoin('project p','p.id = bbd.project_id')
->leftJoin('custom ct','ct.id = p.custom_id')->count();
} }
} }

View File

@ -16,8 +16,12 @@ namespace app\adminapi\lists\bid;
use app\adminapi\lists\BaseAdminDataLists; use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\bid\BidBiddingDecision;
use app\common\model\bid\BidSecurityApply;
use app\common\model\bid\BidSecurityRefund; use app\common\model\bid\BidSecurityRefund;
use app\common\lists\ListsSearchInterface; use app\common\lists\ListsSearchInterface;
use app\common\model\custom\Custom;
use app\common\model\project\Project;
use think\facade\Db; use think\facade\Db;
/** /**
@ -38,7 +42,7 @@ class BidSecurityRefundLists extends BaseAdminDataLists implements ListsSearchIn
public function setSearch(): array public function setSearch(): array
{ {
return [ return [
'=' => ['bsr.bidding_decision_id', 'bsr.refund_date', 'bsr.bank_account_id'], '=' => ['bid_security_apply_id', 'project_id', 'bank_account_id'],
]; ];
} }
@ -54,21 +58,21 @@ class BidSecurityRefundLists extends BaseAdminDataLists implements ListsSearchIn
*/ */
public function lists(): array public function lists(): array
{ {
return Db::name('BidSecurityRefund')->alias('bsr') return BidSecurityRefund::where($this->searchWhere)
->where($this->searchWhere) ->field('id,project_id,bid_security_apply_id,refund_amount,refund_date,remark,annex,bank_account_id,create_time')
->whereNull('bsr.delete_time')
->leftJoin('bid_bidding_decision bbd','bbd.id = bsr.bidding_decision_id')
->leftJoin('project p','p.id = bbd.project_id')
->leftJoin('custom ct','ct.id = p.custom_id')
->field('bsr.*, bbd.project_id, p.name as project_name, p.project_code, ct.name as customer_name')
->limit($this->limitOffset, $this->limitLength) ->limit($this->limitOffset, $this->limitLength)
->order(['bsr.id' => 'desc']) ->order(['id' => 'desc'])
->select()->each(function($item, $key){ ->select()->each(function($data){
//关联数据后续添加 $project = Project::field('custom_id,name,project_code')->where('id',$data['project_id'])->findOrEmpty();
$item['approve_no'] = '付款单号'; $custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty();
$item['approve_step'] = '流程步骤'; $bid_security_apply = BidSecurityApply::field('bidding_decision_id')->where('id',$data['bid_security_apply_id'])->findOrEmpty();
$item['approve_settle_status'] = 1; $bidding_decision = BidBiddingDecision::field('code,bidding_time')->where('id',$bid_security_apply['bidding_decision_id'])->findOrEmpty();
return $item; $data['bidding_decision_code'] = $bidding_decision['code'];
$data['custom_name'] = $custom['name'];
$data['project_name'] = $project['name'];
$data['project_code'] = $project['project_code'];
$data['bidding_time'] = $bidding_decision['bidding_time'];
return $data;
}) })
->toArray(); ->toArray();
} }
@ -82,12 +86,7 @@ class BidSecurityRefundLists extends BaseAdminDataLists implements ListsSearchIn
*/ */
public function count(): int public function count(): int
{ {
return Db::name('BidSecurityRefund')->alias('bsr') return BidSecurityRefund::where($this->searchWhere)->count();
->where($this->searchWhere)
->whereNull('bsr.delete_time')
->leftJoin('bid_bidding_decision bbd','bbd.id = bsr.bidding_decision_id')
->leftJoin('project p','p.id = bbd.project_id')
->leftJoin('custom ct','ct.id = p.custom_id')->count();
} }
} }

View File

@ -17,6 +17,8 @@ namespace app\adminapi\logic\bank;
use app\common\model\bank\BankAccount; use app\common\model\bank\BankAccount;
use app\common\logic\BaseLogic; use app\common\logic\BaseLogic;
use app\common\model\dept\Dept;
use app\common\model\dept\Orgs;
use think\facade\Db; use think\facade\Db;
@ -41,17 +43,16 @@ class BankAccountLogic extends BaseLogic
Db::startTrans(); Db::startTrans();
try { try {
BankAccount::create([ BankAccount::create([
'org_id' => $params['org_id'] ?? 0, 'org_id' => $params['org_id'],
'dept_id' => $params['dept_id'] ?? 0, 'dept_id' => $params['dept_id'],
'account_sn' => $params['account_sn'] ?? '', 'account_sn' => data_unique_code('BANK'),
'deposit_bank' => $params['deposit_bank'] ?? '', 'deposit_bank' => $params['deposit_bank'],
'account_name' => $params['account_name'] ?? '', 'account_name' => $params['account_name'],
'account' => $params['account'] ?? '', 'account' => $params['account'],
'account_opening_date' => $params['account_opening_date'] ?? '', 'account_opening_date' => !empty($params['account_opening_date']) ? strtotime($params['account_opening_date']) : 0,
'opening_amount' => $params['opening_amount'] ?? 0, 'opening_amount' => $params['opening_amount'],
'remark' => $params['remark'] ?? '', 'remark' => $params['remark'] ?? '',
]); ]);
Db::commit(); Db::commit();
return true; return true;
} catch (\Exception $e) { } catch (\Exception $e) {
@ -74,17 +75,15 @@ class BankAccountLogic extends BaseLogic
Db::startTrans(); Db::startTrans();
try { try {
BankAccount::where('id', $params['id'])->update([ BankAccount::where('id', $params['id'])->update([
'org_id' => $params['org_id'] ?? 0, 'org_id' => $params['org_id'],
'dept_id' => $params['dept_id'] ?? 0, 'dept_id' => $params['dept_id'],
'account_sn' => $params['account_sn'] ?? '', 'deposit_bank' => $params['deposit_bank'],
'deposit_bank' => $params['deposit_bank'] ?? '', 'account_name' => $params['account_name'],
'account_name' => $params['account_name'] ?? '', 'account' => $params['account'],
'account' => $params['account'] ?? '', 'account_opening_date' => !empty($params['account_opening_date']) ? strtotime($params['account_opening_date']) : 0,
'account_opening_date' => $params['account_opening_date'] ?? '', 'opening_amount' => $params['opening_amount'],
'opening_amount' => $params['opening_amount'] ?? 0, 'remark' => $params['remark'] ?? '',
'remark' => $params['remark'] ?? '',
]); ]);
Db::commit(); Db::commit();
return true; return true;
} catch (\Exception $e) { } catch (\Exception $e) {
@ -117,6 +116,11 @@ class BankAccountLogic extends BaseLogic
*/ */
public static function detail($params): array public static function detail($params): array
{ {
return BankAccount::findOrEmpty($params['id'])->toArray(); $data = BankAccount::field('id,org_id,dept_id,account_sn,deposit_bank,account_name,account,account_opening_date,opening_amount,remark')->findOrEmpty($params['id']);
$org = Orgs::field('name')->where('id',$data['org_id'])->findOrEmpty();
$dept = Dept::field('name')->where('id',$data['dept_id'])->findOrEmpty();
$data['org_name'] = $org['name'];
$data['dept_name'] = $dept['name'];
return $data->toArray();
} }
} }

View File

@ -15,6 +15,7 @@
namespace app\adminapi\logic\bid; namespace app\adminapi\logic\bid;
use app\common\model\bid\BidBiddingDecision;
use app\common\model\bid\BidSecurityApply; use app\common\model\bid\BidSecurityApply;
use app\common\model\project\Project; use app\common\model\project\Project;
use app\common\model\custom\Custom; use app\common\model\custom\Custom;
@ -40,21 +41,21 @@ class BidSecurityApplyLogic extends BaseLogic
*/ */
public static function add(array $params): bool public static function add(array $params): bool
{ {
$bidding_decision = BidBiddingDecision::field('project_id')->where('id',$params['bidding_decision_id'])->findOrEmpty();
Db::startTrans(); Db::startTrans();
try { try {
BidSecurityApply::create([ BidSecurityApply::create([
'approve_id' => $params['approve_id'] ?? 0, 'project_id' => $bidding_decision['project_id'],
'bidding_decision_id' => $params['bidding_decision_id'] ?? 0, 'bidding_decision_id' => $params['bidding_decision_id'],
'applier' => $params['applier'] ?? '', 'applier' => $params['applier'],
'pay_type' => $params['pay_type'] ?? 0, 'pay_type' => $params['pay_type'],
'refund_date' => $params['refund_date'] ?? '', 'refund_date' => !empty($params['refund_date']) ? strtotime($params['refund_date']) : 0,
'remark' => $params['remark'] ?? '', 'remark' => $params['remark'] ?? '',
'annex' => $params['annex'] ?? '', 'annex' => !empty($params['annex']) ? $params['annex'] : null,
'deposit_bank' => $params['deposit_bank'] ?? '', 'deposit_bank' => $params['deposit_bank'],
'account_name' => $params['account_name'] ?? '', 'account_name' => $params['account_name'],
'account' => $params['account'] ?? '', 'account' => $params['account'],
]); ]);
Db::commit(); Db::commit();
return true; return true;
} catch (\Exception $e) { } catch (\Exception $e) {
@ -74,21 +75,22 @@ class BidSecurityApplyLogic extends BaseLogic
*/ */
public static function edit(array $params): bool public static function edit(array $params): bool
{ {
$bidding_decision = BidBiddingDecision::field('project_id')->where('id',$params['bidding_decision_id'])->findOrEmpty();
Db::startTrans(); Db::startTrans();
try { try {
BidSecurityApply::where('id', $params['id'])->update([ BidSecurityApply::where('id', $params['id'])->update([
'approve_id' => $params['approve_id'] ?? 0, 'security_apply_code' => data_unique_code('投标保证金'),
'bidding_decision_id' => $params['bidding_decision_id'] ?? 0, 'project_id' => $bidding_decision['project_id'],
'applier' => $params['applier'] ?? '', 'bidding_decision_id' => $params['bidding_decision_id'],
'pay_type' => $params['pay_type'] ?? 0, 'applier' => $params['applier'],
'refund_date' => $params['refund_date'] ?? '', 'pay_type' => $params['pay_type'],
'remark' => $params['remark'] ?? '', 'refund_date' => !empty($params['refund_date']) ? strtotime($params['refund_date']) : 0,
'annex' => $params['annex'] ?? '', 'remark' => $params['remark'] ?? '',
'deposit_bank' => $params['deposit_bank'] ?? '', 'annex' => !empty($params['annex']) ? $params['annex'] : null,
'account_name' => $params['account_name'] ?? '', 'deposit_bank' => $params['deposit_bank'],
'account' => $params['account'] ?? '', 'account_name' => $params['account_name'],
'account' => $params['account'],
]); ]);
Db::commit(); Db::commit();
return true; return true;
} catch (\Exception $e) { } catch (\Exception $e) {
@ -121,16 +123,19 @@ class BidSecurityApplyLogic extends BaseLogic
*/ */
public static function detail($params): array public static function detail($params): array
{ {
$bidSecurityApply = BidSecurityApply::findOrEmpty($params['id']); $data = BidSecurityApply::field('id,security_apply_code,project_id,bidding_decision_id,applier,pay_type,refund_date,remark,annex,deposit_bank,account_name,account')
$bidSecurityApply->project = null; ->findOrEmpty($params['id']);
$bidSecurityApply->custom = null; $bidding_decision = BidBiddingDecision::field('code,margin_amount,bidding_time')->where('id',$data['bidding_decision_id'])->findOrEmpty();
if (!empty($bidSecurityApply->decision->project_id)) { $project = Project::field('custom_id,name,project_code')->where('id',$data['project_id'])->findOrEmpty();
$bidSecurityApply->project = Project::findOrEmpty($bidSecurityApply->decision->project_id); $custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty();
} $data['bidding_decision_cod'] = $bidding_decision['code'];
if (!empty($bidSecurityApply->project->custom_id)) { $data['project_name'] = $project['name'];
$bidSecurityApply->custom = Custom::findOrEmpty($bidSecurityApply->project->custom_id); $data['project_code'] = $project['project_code'];
} $data['custom_name'] = $custom['name'];
$bidSecurityApply->annex = json_decode($bidSecurityApply->annex, true); $data['pay_type_text'] = $data->pay_type_text;
return $bidSecurityApply->toArray(); $data['margin_amount'] = $bidding_decision['margin_amount'];
$data['bidding_time'] = $bidding_decision['bidding_time'];
$data['payment_account_info'] = [];
return $data->toArray();
} }
} }

View File

@ -15,6 +15,9 @@
namespace app\adminapi\logic\bid; namespace app\adminapi\logic\bid;
use app\common\model\bank\BankAccount;
use app\common\model\bid\BidBiddingDecision;
use app\common\model\bid\BidSecurityApply;
use app\common\model\bid\BidSecurityRefund; use app\common\model\bid\BidSecurityRefund;
use app\common\logic\BaseLogic; use app\common\logic\BaseLogic;
use app\common\model\project\Project; use app\common\model\project\Project;
@ -40,20 +43,18 @@ class BidSecurityRefundLogic extends BaseLogic
*/ */
public static function add(array $params): bool public static function add(array $params): bool
{ {
$bid_security_apply = BidSecurityApply::field('project_id')->where('id',$params['bid_security_apply_id'])->findOrEmpty();
Db::startTrans(); Db::startTrans();
try { try {
BidSecurityRefund::create([ BidSecurityRefund::create([
'bidding_decision_id' => $params['bidding_decision_id'] ?? 0, 'project_id' => $bid_security_apply['project_id'],
'refund_amount' => $params['refund_amount'] ?? 0, 'bid_security_apply_id' => $params['bid_security_apply_id'],
'refund_amount_daxie' => $params['refund_amount_daxie'] ?? '', 'refund_amount' => $params['refund_amount'],
'refund_date' => $params['refund_date'] ?? '', 'refund_date' => strtotime($params['refund_date']),
'remark' => $params['remark'] ?? '', 'remark' => $params['remark'] ?? '',
'annex' => $params['annex'] ?? '', 'annex' => !empty($params['annex']) ? $params['annex'] : null,
'bank_account_id' => $params['bank_account_id'] ?? 0, 'bank_account_id' => $params['bank_account_id'] ?? 0,
'is_calculate_interest' => $params['is_calculate_interest'] ?? 0,
'interest_calculation_start_date' => $params['interest_calculation_start_date'] ?? '',
]); ]);
Db::commit(); Db::commit();
return true; return true;
} catch (\Exception $e) { } catch (\Exception $e) {
@ -73,18 +74,17 @@ class BidSecurityRefundLogic extends BaseLogic
*/ */
public static function edit(array $params): bool public static function edit(array $params): bool
{ {
$bid_security_apply = BidSecurityApply::field('project_id')->where('id',$params['bid_security_apply_id'])->findOrEmpty();
Db::startTrans(); Db::startTrans();
try { try {
BidSecurityRefund::where('id', $params['id'])->update([ BidSecurityRefund::where('id', $params['id'])->update([
'bidding_decision_id' => $params['bidding_decision_id'] ?? 0, 'project_id' => $bid_security_apply['project_id'],
'refund_amount' => $params['refund_amount'] ?? 0, 'bid_security_apply_id' => $params['bid_security_apply_id'],
'refund_amount_daxie' => $params['refund_amount_daxie'] ?? '', 'refund_amount' => $params['refund_amount'],
'refund_date' => $params['refund_date'] ?? '', 'refund_date' => strtotime($params['refund_date']),
'remark' => $params['remark'] ?? '', 'remark' => $params['remark'] ?? '',
'annex' => $params['annex'] ?? '', 'annex' => !empty($params['annex']) ? $params['annex'] : null,
'bank_account_id' => $params['bank_account_id'] ?? 0, 'bank_account_id' => $params['bank_account_id'] ?? 0,
'is_calculate_interest' => $params['is_calculate_interest'] ?? 0,
'interest_calculation_start_date' => $params['interest_calculation_start_date'] ?? '',
]); ]);
Db::commit(); Db::commit();
@ -119,16 +119,17 @@ class BidSecurityRefundLogic extends BaseLogic
*/ */
public static function detail($params): array public static function detail($params): array
{ {
$bidSecurityRefund = BidSecurityRefund::findOrEmpty($params['id']); $data = BidSecurityRefund::field('id,project_id,bid_security_apply_id,refund_amount,refund_date,remark,annex,bank_account_id')->findOrEmpty($params['id']);
$bidSecurityRefund->project = null; $project = Project::field('custom_id,name,project_code')->where('id',$data['project_id'])->findOrEmpty();
$bidSecurityRefund->custom = null; $custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty();
if (!empty($bidSecurityRefund->decision->project_id)) { $bid_security_apply = BidSecurityApply::field('bidding_decision_id')->where('id',$data['bid_security_apply_id'])->findOrEmpty();
$bidSecurityRefund->project = Project::findOrEmpty($bidSecurityRefund->decision->project_id); $bidding_decision = BidBiddingDecision::field('code,bidding_time')->where('id',$bid_security_apply['bidding_decision_id'])->findOrEmpty();
} $data['bidding_decision_code'] = $bidding_decision['code'];
if (!empty($bidSecurityRefund->project->custom_id)) { $data['custom_name'] = $custom['name'];
$bidSecurityRefund->custom = Custom::findOrEmpty($bidSecurityRefund->project->custom_id); $data['project_name'] = $project['name'];
} $data['project_code'] = $project['project_code'];
$bidSecurityRefund->annex = json_decode($bidSecurityRefund->annex, true); $data['bidding_time'] = $bidding_decision['bidding_time'];
return $bidSecurityRefund->toArray(); $data['bank_account_info'] = BankAccount::field('account_sn,deposit_bank,account_name,account')->where('id',$data['bank_account_id'])->findOrEmpty();
return $data->toArray();
} }
} }

View File

@ -15,6 +15,8 @@
namespace app\adminapi\validate\bank; namespace app\adminapi\validate\bank;
use app\common\model\dept\Dept;
use app\common\model\dept\Orgs;
use app\common\validate\BaseValidate; use app\common\validate\BaseValidate;
@ -32,12 +34,13 @@ class BankAccountValidate extends BaseValidate
*/ */
protected $rule = [ protected $rule = [
'id' => 'require', 'id' => 'require',
'org_id' => 'require', 'org_id' => 'require|checkOrg',
'dept_id' => 'require', 'dept_id' => 'require|checkDept',
'deposit_bank' => 'require', 'deposit_bank' => 'require',
'account_name' => 'require', 'account_name' => 'require',
'account' => 'require', 'account' => 'require',
'opening_amount' => 'require', 'account_opening_date' => 'dateFormat:Y-m-d',
'opening_amount' => 'require|float|egt:0',
]; ];
@ -47,11 +50,12 @@ class BankAccountValidate extends BaseValidate
*/ */
protected $field = [ protected $field = [
'id' => 'id', 'id' => 'id',
'org_id' => '组织id', 'org_id' => '组织',
'dept_id' => '部门id', 'dept_id' => '部门',
'deposit_bank' => '开户银行', 'deposit_bank' => '开户银行',
'account_name' => '开户名称', 'account_name' => '开户名称',
'account' => '账号', 'account' => '账号',
'account_opening_date' => '开户日期',
'opening_amount' => '期初金额', 'opening_amount' => '期初金额',
]; ];
@ -64,7 +68,7 @@ class BankAccountValidate extends BaseValidate
*/ */
public function sceneAdd() public function sceneAdd()
{ {
return $this->only(['org_id','dept_id','deposit_bank','account_name','account','opening_amount']); return $this->remove('id',true);
} }
@ -75,9 +79,7 @@ class BankAccountValidate extends BaseValidate
* @date 2023/12/20 15:04 * @date 2023/12/20 15:04
*/ */
public function sceneEdit() public function sceneEdit()
{ {}
return $this->only(['id','org_id','dept_id','deposit_bank','account_name','account','opening_amount']);
}
/** /**
@ -103,4 +105,25 @@ class BankAccountValidate extends BaseValidate
return $this->only(['id']); return $this->only(['id']);
} }
public function checkOrg($value): bool|string
{
$org = Orgs::where('id',$value)->findOrEmpty();
if($org->isEmpty()){
return '组织不存在';
}
return true;
}
public function checkDept($value,$rule,$data): bool|string
{
$dept = Dept::where('id',$value)->findOrEmpty();
if($dept->isEmpty()){
return '部门不存在';
}
if($dept['org_id'] != $data['org_id']){
return '部门无效';
}
return true;
}
} }

View File

@ -15,6 +15,8 @@
namespace app\adminapi\validate\bid; namespace app\adminapi\validate\bid;
use app\common\model\bid\BidBiddingDecision;
use app\common\model\dict\DictData;
use app\common\validate\BaseValidate; use app\common\validate\BaseValidate;
@ -32,10 +34,11 @@ class BidSecurityApplyValidate extends BaseValidate
*/ */
protected $rule = [ protected $rule = [
'id' => 'require', 'id' => 'require',
'approve_id' => 'require', 'bidding_decision_id' => 'require|checkBiddingDecision',
'bidding_decision_id' => 'require',
'applier' => 'require', 'applier' => 'require',
'pay_type' => 'require', 'pay_type' => 'require|checkPayType',
'refund_date' => 'dateFormat:Y-m-d',
'annex' => 'checkAnnex',
'deposit_bank' => 'require', 'deposit_bank' => 'require',
'account_name' => 'require', 'account_name' => 'require',
'account' => 'require', 'account' => 'require',
@ -48,9 +51,10 @@ class BidSecurityApplyValidate extends BaseValidate
*/ */
protected $field = [ protected $field = [
'id' => 'id', 'id' => 'id',
'bidding_decision_id' => '投标决策id', 'bidding_decision_id' => '投标决策',
'applier' => '申请人', 'applier' => '申请人',
'pay_type' => '付款方式', 'pay_type' => '付款方式',
'refund_date' => '预计退还时间',
'deposit_bank' => '开户银行', 'deposit_bank' => '开户银行',
'account_name' => '开户名称', 'account_name' => '开户名称',
'account' => '账号', 'account' => '账号',
@ -65,7 +69,7 @@ class BidSecurityApplyValidate extends BaseValidate
*/ */
public function sceneAdd() public function sceneAdd()
{ {
return $this->only(['approve_id','bidding_decision_id','applier','pay_type','deposit_bank','account_name','account']); return $this->remove('id',true);
} }
@ -76,9 +80,7 @@ class BidSecurityApplyValidate extends BaseValidate
* @date 2023/12/16 10:46 * @date 2023/12/16 10:46
*/ */
public function sceneEdit() public function sceneEdit()
{ {}
return $this->only(['id','approve_id','bidding_decision_id','applier','pay_type','deposit_bank','account_name','account']);
}
/** /**
@ -104,4 +106,33 @@ class BidSecurityApplyValidate extends BaseValidate
return $this->only(['id']); return $this->only(['id']);
} }
public function checkBiddingDecision($value): bool|string
{
$data = BidBiddingDecision::where('id',$value)->findOrEmpty();
if($data->isEmpty()){
return '投标决策信息不存在';
}
return true;
}
public function checkPayType($value): bool|string
{
$dict = DictData::where('type_value','pay_type')->column('value');
if(!in_array($value,$dict)){
return '付款方式无效';
}
return true;
}
public function checkAnnex($value): bool|string
{
if(!empty($value) && $value != ''){
$annex = json_decode($value,true);
if(empty($annex) || !is_array($annex)){
return '附件格式错误';
}
}
return true;
}
} }

View File

@ -15,6 +15,8 @@
namespace app\adminapi\validate\bid; namespace app\adminapi\validate\bid;
use app\common\model\bank\BankAccount;
use app\common\model\bid\BidSecurityApply;
use app\common\validate\BaseValidate; use app\common\validate\BaseValidate;
@ -32,10 +34,11 @@ class BidSecurityRefundValidate extends BaseValidate
*/ */
protected $rule = [ protected $rule = [
'id' => 'require', 'id' => 'require',
'bidding_decision_id' => 'require', 'bid_security_apply_id' => 'require|checkBidSecurityApply',
'refund_amount' => 'require', 'refund_amount' => 'require|float|egt:0',
'refund_date' => 'require', 'refund_date' => 'require|dateFormat:Y-m-d',
'bank_account_id' => 'require', 'annex' => 'checkAnnex',
'bank_account_id' => 'require|checkBankAccount',
]; ];
@ -45,10 +48,10 @@ class BidSecurityRefundValidate extends BaseValidate
*/ */
protected $field = [ protected $field = [
'id' => 'id', 'id' => 'id',
'bidding_decision_id' => '投标决策id', 'bid_security_apply_id' => '投标保证金id',
'refund_amount' => '退款金额', 'refund_amount' => '退款金额',
'refund_date' => '退款日期', 'refund_date' => '退款日期',
'bank_account_id' => '银行账号id', 'bank_account_id' => '银行账号',
]; ];
@ -60,7 +63,7 @@ class BidSecurityRefundValidate extends BaseValidate
*/ */
public function sceneAdd() public function sceneAdd()
{ {
return $this->only(['bidding_decision_id','refund_amount','refund_date','bank_account_id']); return $this->remove('id',true);
} }
@ -71,9 +74,7 @@ class BidSecurityRefundValidate extends BaseValidate
* @date 2023/12/18 10:29 * @date 2023/12/18 10:29
*/ */
public function sceneEdit() public function sceneEdit()
{ {}
return $this->only(['id','bidding_decision_id','refund_amount','refund_date','bank_account_id']);
}
/** /**
@ -99,4 +100,33 @@ class BidSecurityRefundValidate extends BaseValidate
return $this->only(['id']); return $this->only(['id']);
} }
public function checkBidSecurityApply($value): bool|string
{
$data = BidSecurityApply::where('id',$value)->findOrEmpty();
if($data->isEmpty()){
return '投标保证金信息不存在';
}
return true;
}
public function checkAnnex($value): bool|string
{
if(!empty($value) && $value != ''){
$annex = json_decode($value,true);
if(empty($annex) || !is_array($annex)){
return '附件格式错误';
}
}
return true;
}
public function checkBankAccount($value): bool|string
{
$data = BankAccount::where('id',$value)->findOrEmpty();
if($data->isEmpty()){
return '银行账户信息不存在';
}
return true;
}
} }

View File

@ -30,5 +30,8 @@ class BankAccount extends BaseModel
protected $name = 'bank_account'; protected $name = 'bank_account';
protected $deleteTime = 'delete_time'; protected $deleteTime = 'delete_time';
public function getAccountOpeningDateAttr($value): string
{
return !empty($value) ? date('Y-m-d',$value) : '';
}
} }

View File

@ -16,6 +16,7 @@ namespace app\common\model\bid;
use app\common\model\BaseModel; use app\common\model\BaseModel;
use app\common\model\dict\DictData;
use think\model\concern\SoftDelete; use think\model\concern\SoftDelete;
@ -31,9 +32,17 @@ class BidSecurityApply extends BaseModel
protected $name = 'bid_security_apply'; protected $name = 'bid_security_apply';
protected $deleteTime = 'delete_time'; protected $deleteTime = 'delete_time';
public function getAnnexAttr($value){
return !empty($value) ? json_decode($value,true) : '';
}
public function decision() public function getRefundDateAttr($value): string
{ {
return $this->belongsTo(\app\common\model\bid\BidBiddingDecision::class, 'bidding_decision_id'); return !empty($value) ? date('Y-m-d',$value) : '';
} }
public function getPayTypeTextAttr($value,$data){
$dict = DictData::where('type_value','pay_type')->column('name','value');
return $dict[$data['pay_type']];
}
} }

View File

@ -30,16 +30,13 @@ class BidSecurityRefund extends BaseModel
protected $name = 'bid_security_refund'; protected $name = 'bid_security_refund';
protected $deleteTime = 'delete_time'; protected $deleteTime = 'delete_time';
public function getAnnexAttr($value){
return !empty($value) ? json_decode($value,true) : '';
}
/** public function getRefundDateAttr($value): string
* @notes 关联decision {
* @return \think\model\relation\HasOne return !empty($value) ? date('Y-m-d',$value) : '';
* @author likeadmin }
* @date 2023/12/18 10:29
*/
public function decision()
{
return $this->belongsTo(\app\common\model\bid\BidBiddingDecision::class, 'bidding_decision_id');
}
} }