Merge pull request 'zhangwei' (#157) from zhangwei into dev
Reviewed-on: #157
This commit is contained in:
commit
a334b89c56
@ -16,9 +16,9 @@
|
||||
namespace app\adminapi\controller\finance;
|
||||
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\finance\FinanceReturnedMoneyLists;
|
||||
use app\adminapi\logic\finance\FinanceReturnedMoneyLogic;
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\finance\FinanceReturnedMoneyLists;
|
||||
use app\adminapi\logic\finance\FinanceReturnedMoneyLogic;
|
||||
use app\adminapi\validate\finance\FinanceReturnedMoneyValidate;
|
||||
|
||||
|
||||
|
@ -67,7 +67,7 @@ class BidSecurityApplyLists extends BaseAdminDataLists implements ListsSearchInt
|
||||
$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_cod'] = $bidding_decision['code'];
|
||||
$data['bidding_decision_code'] = $bidding_decision['code'];
|
||||
$data['project_name'] = $project['name'];
|
||||
$data['project_code'] = $project['project_code'];
|
||||
$data['custom_name'] = $custom['name'];
|
||||
|
@ -16,6 +16,7 @@ namespace app\adminapi\lists\bid;
|
||||
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\bank\BankAccount;
|
||||
use app\common\model\bid\BidBiddingDecision;
|
||||
use app\common\model\bid\BidSecurityApply;
|
||||
use app\common\model\bid\BidSecurityRefund;
|
||||
@ -72,6 +73,7 @@ class BidSecurityRefundLists extends BaseAdminDataLists implements ListsSearchIn
|
||||
$data['project_name'] = $project['name'];
|
||||
$data['project_code'] = $project['project_code'];
|
||||
$data['bidding_time'] = $bidding_decision['bidding_time'];
|
||||
$data['bank_account_info'] = BankAccount::field('account_sn,deposit_bank,account_name,account')->where('id',$data['bank_account_id'])->findOrEmpty();
|
||||
return $data;
|
||||
})
|
||||
->toArray();
|
||||
|
@ -16,6 +16,8 @@ namespace app\adminapi\lists\finance;
|
||||
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\contract\Contract;
|
||||
use app\common\model\finance\FinanceReturnedMoney;
|
||||
use app\common\model\project\Project;
|
||||
use app\common\model\custom\Custom;
|
||||
@ -41,7 +43,7 @@ class FinanceReturnedMoneyLists extends BaseAdminDataLists implements ListsSearc
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['frm.customer_id', 'frm.contract_id', 'frm.return_status'],
|
||||
'=' => ['project_id', 'contract_id', 'return_status', 'period'],
|
||||
];
|
||||
}
|
||||
|
||||
@ -57,18 +59,33 @@ class FinanceReturnedMoneyLists extends BaseAdminDataLists implements ListsSearc
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return Db::name('FinanceReturnedMoney')->alias('frm')
|
||||
->where($this->searchWhere)
|
||||
->whereNull('frm.delete_time')
|
||||
->leftJoin('contract c','c.id = frm.contract_id')
|
||||
->leftJoin('bid_buy_bidding_document bbbd','bbbd.id = c.buy_bidding_document_id')
|
||||
->leftJoin('project p','p.id = bbbd.project_id')
|
||||
->leftJoin('custom ct','ct.id = c.customer_id')
|
||||
->field('frm.*, bbbd.project_id, c.contract_code, c.contract_name, c.contract_type, p.name as project_name, p.project_code, ct.name as customer_name')
|
||||
$params = $this->request->get(['custom_id']);
|
||||
$where = [];
|
||||
if(isset($params['custom_id']) && $params['custom_id'] != ''){
|
||||
$project_ids = Project::where('custom_id',$params['custom_id'])->column('id');
|
||||
$where[] = ['project_id','in',$project_ids];
|
||||
}
|
||||
return FinanceReturnedMoney::where($this->searchWhere)->where($where)
|
||||
->field('id,project_id,contract_id,return_date,period,amount,return_status,return_duty_id,remark')
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['frm.id' => 'desc'])
|
||||
->select()->each(function($item, $key){
|
||||
return $item;
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function($data){
|
||||
$project = Project::field('custom_id,name,project_code')->where('id',$data['project_id'])->findOrEmpty();
|
||||
$custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty();
|
||||
$contract = Contract::field('contract_name,contract_code,contract_type')->where('id',$data['contract_id'])->findOrEmpty();
|
||||
$return_duty = Admin::field('name')->where('id',$data['return_duty_id'])->findOrEmpty();
|
||||
$data['project_name'] = $project['name'];
|
||||
$data['project_code'] = $project['project_code'];
|
||||
$data['custom_name'] = $custom['name'];
|
||||
$data['contract_name'] = $contract['contract_name'];
|
||||
$data['contract_code'] = $contract['contract_code'];
|
||||
$data['contract_type'] = $contract->contract_type_text;
|
||||
$data['period'] = $data->period_text;
|
||||
$data['return_status'] = $data->return_status_text;
|
||||
$data['return_duty'] = $return_duty['name'];
|
||||
$data['has_return_amount'] = 0;
|
||||
$data['not_return_amount'] = $data['amount'] - $data['has_return_amount'];
|
||||
return $data;
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
@ -82,13 +99,13 @@ class FinanceReturnedMoneyLists extends BaseAdminDataLists implements ListsSearc
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return Db::name('FinanceReturnedMoney')->alias('frm')
|
||||
->where($this->searchWhere)
|
||||
->whereNull('frm.delete_time')
|
||||
->leftJoin('contract c','c.id = frm.contract_id')
|
||||
->leftJoin('bid_buy_bidding_document bbbd','bbbd.id = c.buy_bidding_document_id')
|
||||
->leftJoin('project p','p.id = bbbd.project_id')
|
||||
->leftJoin('custom ct','ct.id = c.customer_id')->count();
|
||||
$params = $this->request->get(['custom_id']);
|
||||
$where = [];
|
||||
if(isset($params['custom_id']) && $params['custom_id'] != ''){
|
||||
$project_ids = Project::where('custom_id',$params['custom_id'])->column('id');
|
||||
$where[] = ['project_id','in',$project_ids];
|
||||
}
|
||||
return FinanceReturnedMoney::where($this->searchWhere)->where($where)->count();
|
||||
}
|
||||
|
||||
}
|
@ -129,7 +129,7 @@ class BidSecurityApplyLogic extends BaseLogic
|
||||
$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_cod'] = $bidding_decision['code'];
|
||||
$data['bidding_decision_code'] = $bidding_decision['code'];
|
||||
$data['project_name'] = $project['name'];
|
||||
$data['project_code'] = $project['project_code'];
|
||||
$data['custom_name'] = $custom['name'];
|
||||
|
@ -15,6 +15,8 @@
|
||||
namespace app\adminapi\logic\finance;
|
||||
|
||||
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\contract\Contract;
|
||||
use app\common\model\finance\FinanceReturnedMoney;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\project\Project;
|
||||
@ -40,20 +42,20 @@ class FinanceReturnedMoneyLogic extends BaseLogic
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
$contract = Contract::field('project_id')->where('id',$params['contract_id'])->findOrEmpty();
|
||||
Db::startTrans();
|
||||
try {
|
||||
FinanceReturnedMoney::create([
|
||||
'customer_id' => $params['customer_id'] ?? 0,
|
||||
'contract_id' => $params['contract_id'] ?? 0,
|
||||
'return_date' => $params['return_date'] ?? '',
|
||||
'period' => $params['period'] ?? '',
|
||||
'amount' => $params['amount'] ?? 0,
|
||||
'return_status' => $params['return_status'] ?? 0,
|
||||
'return_duty_id' => $params['return_duty_id'] ?? 0,
|
||||
'project_id' => $contract['project_id'],
|
||||
'contract_id' => $params['contract_id'],
|
||||
'return_date' => strtotime($params['return_date']),
|
||||
'period' => $params['period'],
|
||||
'amount' => $params['amount'],
|
||||
'return_status' => $params['return_status'],
|
||||
'return_duty_id' => $params['return_duty_id'],
|
||||
'remark' => $params['remark'] ?? '',
|
||||
'annex' => $params['annex'] ?? '',
|
||||
'annex' => !empty($params['annex']) ? $params['annex'] : null,
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
@ -73,20 +75,20 @@ class FinanceReturnedMoneyLogic extends BaseLogic
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
$contract = Contract::field('project_id')->where('id',$params['contract_id'])->findOrEmpty();
|
||||
Db::startTrans();
|
||||
try {
|
||||
FinanceReturnedMoney::where('id', $params['id'])->update([
|
||||
'customer_id' => $params['customer_id'] ?? 0,
|
||||
'contract_id' => $params['contract_id'] ?? 0,
|
||||
'return_date' => $params['return_date'] ?? '',
|
||||
'period' => $params['period'] ?? '',
|
||||
'amount' => $params['amount'] ?? 0,
|
||||
'return_status' => $params['return_status'] ?? 0,
|
||||
'return_duty_id' => $params['return_duty_id'] ?? 0,
|
||||
'remark' => $params['remark'] ?? '',
|
||||
'annex' => $params['annex'] ?? '',
|
||||
'project_id' => $contract['project_id'],
|
||||
'contract_id' => $params['contract_id'],
|
||||
'return_date' => strtotime($params['return_date']),
|
||||
'period' => $params['period'],
|
||||
'amount' => $params['amount'],
|
||||
'return_status' => $params['return_status'],
|
||||
'return_duty_id' => $params['return_duty_id'],
|
||||
'remark' => $params['remark'] ?? '',
|
||||
'annex' => !empty($params['annex']) ? $params['annex'] : null,
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
@ -119,20 +121,19 @@ class FinanceReturnedMoneyLogic extends BaseLogic
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
$financeReturnedMoney = FinanceReturnedMoney::findOrEmpty($params['id']);
|
||||
$financeReturnedMoney->contract;
|
||||
$financeReturnedMoney->custom;
|
||||
$financeReturnedMoney->document = null;
|
||||
$financeReturnedMoney->project = null;
|
||||
if (!empty($financeReturnedMoney->contract->document)) {
|
||||
$financeReturnedMoney->document = $financeReturnedMoney->contract->document;
|
||||
unset($financeReturnedMoney->contract->document);
|
||||
}
|
||||
if (!empty($financeReturnedMoney->document->project)) {
|
||||
$financeReturnedMoney->project = $financeReturnedMoney->document->project;
|
||||
unset($financeReturnedMoney->document->project);
|
||||
}
|
||||
$financeReturnedMoney->annex = json_decode($financeReturnedMoney->annex, true);
|
||||
return $financeReturnedMoney->toArray();
|
||||
$data = FinanceReturnedMoney::field('id,project_id,contract_id,return_date,period,amount,return_status,return_duty_id,remark,annex')->findOrEmpty($params['id']);
|
||||
$project = Project::field('custom_id,name,project_code')->where('id',$data['project_id'])->findOrEmpty();
|
||||
$custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty();
|
||||
$contract = Contract::field('contract_name,contract_code')->where('id',$data['contract_id'])->findOrEmpty();
|
||||
$return_duty = Admin::field('name')->where('id',$data['return_duty_id'])->findOrEmpty();
|
||||
$data['project_name'] = $project['name'];
|
||||
$data['project_code'] = $project['project_code'];
|
||||
$data['custom_name'] = $custom['name'];
|
||||
$data['contract_name'] = $contract['contract_name'];
|
||||
$data['contract_code'] = $contract['contract_code'];
|
||||
$data['period_text'] = $data->period_text;
|
||||
$data['return_status_text'] = $data->return_status_text;
|
||||
$data['return_duty'] = $return_duty['name'];
|
||||
return $data->toArray();
|
||||
}
|
||||
}
|
@ -15,6 +15,9 @@
|
||||
namespace app\adminapi\validate\finance;
|
||||
|
||||
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\contract\Contract;
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
@ -32,8 +35,13 @@ class FinanceReturnedMoneyValidate extends BaseValidate
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'customer_id' => 'require',
|
||||
'contract_id' => 'require',
|
||||
'contract_id' => 'require|checkContract',
|
||||
'return_date' => 'require|dateFormat:Y-m-d',
|
||||
'period' => 'require|checkPeriod',
|
||||
'amount' => 'require|float|gt:0',
|
||||
'return_status' => 'require|checkReturnStatus',
|
||||
'return_duty_id' => 'require|checkReturnDuty',
|
||||
'annex' => 'checkAnnex'
|
||||
];
|
||||
|
||||
|
||||
@ -42,7 +50,13 @@ class FinanceReturnedMoneyValidate extends BaseValidate
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
'id' => 'require',
|
||||
'contract_id' => '项目合同',
|
||||
'return_date' => '计划回款日期',
|
||||
'period' => '期次',
|
||||
'amount' => '金额',
|
||||
'return_status' => '回款状态',
|
||||
'return_duty_id' => '回款责任人',
|
||||
];
|
||||
|
||||
|
||||
@ -65,9 +79,7 @@ class FinanceReturnedMoneyValidate extends BaseValidate
|
||||
* @date 2023/12/13 15:38
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id', 'customer_id', 'contract_id']);
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/**
|
||||
@ -92,5 +104,52 @@ class FinanceReturnedMoneyValidate extends BaseValidate
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function checkContract($value): bool|string
|
||||
{
|
||||
$data = Contract::where('id',$value)->findOrEmpty();
|
||||
if($data->isEmpty()){
|
||||
return '项目合同不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkPeriod($value): bool|string
|
||||
{
|
||||
$dict = DictData::where('type_value','pay_period')->column('value');
|
||||
if(!in_array($value,$dict)){
|
||||
return '期次无效';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkReturnStatus($value): bool|string
|
||||
{
|
||||
$dict = DictData::where('type_value','return_status')->column('value');
|
||||
if(!in_array($value,$dict)){
|
||||
return '回款状态无效';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkReturnDuty($value): bool|string
|
||||
{
|
||||
$data = Admin::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;
|
||||
}
|
||||
|
||||
}
|
@ -16,6 +16,7 @@ namespace app\common\model\finance;
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use app\common\model\dict\DictData;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
|
||||
@ -29,15 +30,24 @@ class FinanceReturnedMoney extends BaseModel
|
||||
use SoftDelete;
|
||||
protected $name = 'finance_returned_money';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
public function custom()
|
||||
{
|
||||
return $this->belongsTo(\app\common\model\custom\Custom::class, 'customer_id');
|
||||
}
|
||||
|
||||
public function contract()
|
||||
{
|
||||
return $this->belongsTo(\app\common\model\contract\Contract::class, 'contract_id');
|
||||
}
|
||||
|
||||
public function getAnnexAttr($value){
|
||||
return !empty($value) ? json_decode($value,true) : '';
|
||||
}
|
||||
|
||||
public function getPeriodTextAttr($value,$data){
|
||||
$dict = DictData::where('type_value','pay_period')->column('name','value');
|
||||
return $dict[$data['period']];
|
||||
}
|
||||
|
||||
public function getReturnStatusTextAttr($value,$data){
|
||||
$dict = DictData::where('type_value','return_status')->column('name','value');
|
||||
return $dict[$data['return_status']];
|
||||
}
|
||||
|
||||
public function getReturnDateAttr($value): string
|
||||
{
|
||||
return !empty($value) ? date('Y-m-d',$value) : '';
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user