Merge pull request 'update' (#176) from zhangwei into dev
Reviewed-on: #176
This commit is contained in:
commit
d3e6072bdf
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller\finance;
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\common\model\contract\ProcurementContract;
|
||||
use app\common\model\contract\SubcontractingContract;
|
||||
use app\common\model\contract\SubcontractingContractNegotiation;
|
||||
use app\common\model\finance\FinancePaymentPlan;
|
||||
use app\common\model\finance\FinanceReceiptRecord;
|
||||
use app\common\model\project\Project;
|
||||
use app\common\model\supplier\Supplier;
|
||||
|
||||
class FinancePaymentReceiptDifferenceController extends BaseAdminController
|
||||
{
|
||||
//采购付款与收票差异
|
||||
public function procure(): \think\response\Json
|
||||
{
|
||||
$params = $this->request->get(['page_no','page_size','contract_code','project_id']);
|
||||
$pageNo = empty($params['page_no']) ? 1 : $params['page_no'];
|
||||
$pageSize = empty($params['page_size']) ? 15 : $params['page_size'];
|
||||
$where = [];
|
||||
if(isset($params['project_id']) && $params['project_id']){
|
||||
$where[] = ['project_id','=',$params['project_id']];
|
||||
}
|
||||
if(isset($params['contract_no']) && $params['contract_no']){
|
||||
$where[] = ['contract_no','like','%'.$params['contract_no'].'%'];
|
||||
}
|
||||
$data = ProcurementContract::field('id,supplier_id,project_id,contract_no,signing_date,contract_amount')->where($where)->page($pageNo,$pageSize)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function($item){
|
||||
$project = Project::field('name,project_code')->where('id',$item['project_id'])->findOrEmpty();
|
||||
$supplier = Supplier::field('supplier_name,supplier_code')->where('id',$item['supplier_id'])->findOrEmpty();
|
||||
$item['project_name'] = $project['name'];
|
||||
$item['project_code'] = $project['project_code'];
|
||||
$item['supplier_name'] = $supplier['supplier_name'];
|
||||
$item['supplier_code'] = $supplier['supplier_code'];
|
||||
//已付款金额
|
||||
$item['has_payment_amount'] = FinancePaymentPlan::where('contract_id',$item['id'])->where('contract_type',1)->sum('amount');
|
||||
//已收票金额
|
||||
$item['has_receipt_amount'] = FinanceReceiptRecord::where('contract_id',$item['id'])->where('contract_type',1)->sum('invoice_amount');
|
||||
//收票未付款
|
||||
$item['has_receipt_not_payment_amount'] = ($item['has_receipt_amount'] - $item['has_payment_amount']) <= 0 ? 0 : $item['has_receipt_amount'] - $item['has_payment_amount'];
|
||||
//付款未收票
|
||||
$item['has_payment_not_receipt_amount'] = ($item['has_payment_amount'] - $item['has_receipt_amount']) <= 0 ? 0 : $item['has_payment_amount'] - $item['has_receipt_amount'];
|
||||
return $item;
|
||||
})->toArray();
|
||||
$count = ProcurementContract::field('id')->where($where)->count();
|
||||
$result = [
|
||||
'count' => $count,
|
||||
'page_no' => $pageNo,
|
||||
'page_size' => $pageSize,
|
||||
'lists' => $data
|
||||
];
|
||||
return $this->success('请求成功',$result);
|
||||
}
|
||||
|
||||
//分包付款与收票差异
|
||||
public function subcontract(): \think\response\Json
|
||||
{
|
||||
$params = $this->request->get(['page_no','page_size','contract_code','project_id']);
|
||||
$pageNo = empty($params['page_no']) ? 1 : $params['page_no'];
|
||||
$pageSize = empty($params['page_size']) ? 15 : $params['page_size'];
|
||||
$where = [];
|
||||
$data = SubcontractingContract::field('id,supplier_id,project_id,contract_no,signing_date,contract_amount')->where($where)->page($pageNo,$pageSize)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function($item){
|
||||
$project = Project::field('name,project_code')->where('id',$item['project_id'])->findOrEmpty();
|
||||
$supplier = Supplier::field('supplier_name,supplier_code')->where('id',$item['supplier_id'])->findOrEmpty();
|
||||
$item['project_name'] = $project['name'];
|
||||
$item['project_code'] = $project['project_code'];
|
||||
$item['supplier_name'] = $supplier['supplier_name'];
|
||||
$item['supplier_code'] = $supplier['supplier_code'];
|
||||
//洽商金额
|
||||
$negotiate_amount = SubcontractingContractNegotiation::where('subcontracting_contract_id',$item['id'])->sum('negotiation_amount');
|
||||
//实际合同金额
|
||||
$item['contract_amount'] = $item['contract_amount'] + $negotiate_amount;
|
||||
//已付款金额
|
||||
$item['has_payment_amount'] = FinancePaymentPlan::where('contract_id',$item['id'])->where('contract_type',2)->sum('amount');
|
||||
//已收票金额
|
||||
$item['has_receipt_amount'] = FinanceReceiptRecord::where('contract_id',$item['id'])->where('contract_type',2)->sum('invoice_amount');
|
||||
//收票未付款
|
||||
$item['has_receipt_not_payment_amount'] = ($item['has_receipt_amount'] - $item['has_payment_amount']) <= 0 ? 0 : $item['has_receipt_amount'] - $item['has_payment_amount'];
|
||||
//付款未收票
|
||||
$item['has_payment_not_receipt_amount'] = ($item['has_payment_amount'] - $item['has_receipt_amount']) <= 0 ? 0 : $item['has_payment_amount'] - $item['has_receipt_amount'];
|
||||
return $item;
|
||||
})->toArray();
|
||||
$count = SubcontractingContract::field('id')->where($where)->count();
|
||||
$result = [
|
||||
'count' => $count,
|
||||
'page_no' => $pageNo,
|
||||
'page_size' => $pageSize,
|
||||
'lists' => $data
|
||||
];
|
||||
return $this->success('请求成功',$result);
|
||||
}
|
||||
}
|
@ -12,11 +12,18 @@
|
||||
|
||||
class FinanceRefundInvoiceDifferenceController extends BaseAdminController
|
||||
{
|
||||
public function lists() {
|
||||
$params = $this->request->get(['page_no','page_size']);
|
||||
public function lists(): \think\response\Json
|
||||
{
|
||||
$params = $this->request->get(['page_no','page_size','contract_code','project_id']);
|
||||
$pageNo = empty($params['page_no']) ? 1 : $params['page_no'];
|
||||
$pageSize = empty($params['page_size']) ? 15 : $params['page_size'];
|
||||
$where = [];
|
||||
if(isset($params['project_id']) && $params['project_id']){
|
||||
$where[] = ['project_id','=',$params['project_id']];
|
||||
}
|
||||
if(isset($params['contract_code']) && $params['contract_code']){
|
||||
$where[] = ['contract_code','like','%'.$params['contract_code'].'%'];
|
||||
}
|
||||
$data = Contract::field('id,project_id,contract_code,contract_name,contract_date,amount')->where($where)
|
||||
->page($pageNo,$pageSize)
|
||||
->order(['id' => 'desc'])
|
||||
@ -41,6 +48,13 @@
|
||||
unset($item['amount']);
|
||||
return $item;
|
||||
})->toArray();
|
||||
halt($data);
|
||||
$count = Contract::field('id')->where($where)->count();
|
||||
$result = [
|
||||
'count' => $count,
|
||||
'page_no' => $pageNo,
|
||||
'page_size' => $pageSize,
|
||||
'lists' => $data
|
||||
];
|
||||
return $this->success('请求成功',$result);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user