update
This commit is contained in:
parent
092ad6f08f
commit
73f7c17286
@ -58,6 +58,15 @@ class ProjectSalaryPaymentController extends BaseAdminController
|
|||||||
}
|
}
|
||||||
return $this->fail(ProjectSalaryPaymentLogic::getError());
|
return $this->fail(ProjectSalaryPaymentLogic::getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function edit() {
|
||||||
|
$params = (new ProjectSalaryPaymentValidate())->post()->goCheck('edit');
|
||||||
|
$result = ProjectSalaryPaymentLogic::edit($params);
|
||||||
|
if (true === $result) {
|
||||||
|
return $this->success('编辑成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
return $this->fail(ProjectSalaryPaymentLogic::getError());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,7 +44,9 @@ class ProjectSalaryDetailLists extends BaseAdminDataLists implements ListsSearch
|
|||||||
*/
|
*/
|
||||||
public function setSearch(): array
|
public function setSearch(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [
|
||||||
|
'=' => ['salary_payment_id'],
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -59,7 +61,23 @@ class ProjectSalaryDetailLists extends BaseAdminDataLists implements ListsSearch
|
|||||||
*/
|
*/
|
||||||
public function lists(): array
|
public function lists(): array
|
||||||
{
|
{
|
||||||
return ProjectSalaryDetail::where($this->searchWhere)
|
$prarms = $this->request->get(['payment_code','project_name','project_code']);
|
||||||
|
$where = [];
|
||||||
|
if(isset($prarms['payment_code']) && $prarms['payment_code'] != ''){
|
||||||
|
$salary_payment_ids = ProjectSalaryPayment::where('payment_code','like','%'.$prarms['payment_code'].'%')->column('id');
|
||||||
|
$where[] = ['salary_payment_id','in',$salary_payment_ids];
|
||||||
|
}
|
||||||
|
if(isset($prarms['project_name']) && $prarms['project_name'] != ''){
|
||||||
|
$project_ids = Project::where('name','like','%'.$prarms['project_name'].'%')->column('id');
|
||||||
|
$salary_payment_ids = ProjectSalaryPayment::where('project_id','in',$project_ids)->column('id');
|
||||||
|
$where[] = ['salary_payment_id','in',$salary_payment_ids];
|
||||||
|
}
|
||||||
|
if(isset($prarms['project_code']) && $prarms['project_code'] != ''){
|
||||||
|
$project_ids = Project::where('name','like','%'.$prarms['project_code'].'%')->column('id');
|
||||||
|
$salary_payment_ids = ProjectSalaryPayment::where('project_id','in',$project_ids)->column('id');
|
||||||
|
$where[] = ['salary_payment_id','in',$salary_payment_ids];
|
||||||
|
}
|
||||||
|
return ProjectSalaryDetail::where($this->searchWhere)->where($where)
|
||||||
->field(['id', 'salary_payment_id', 'person_id', 'apply_date', 'apply_amount', 'remark'])
|
->field(['id', 'salary_payment_id', 'person_id', 'apply_date', 'apply_amount', 'remark'])
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
@ -102,7 +120,23 @@ class ProjectSalaryDetailLists extends BaseAdminDataLists implements ListsSearch
|
|||||||
*/
|
*/
|
||||||
public function count(): int
|
public function count(): int
|
||||||
{
|
{
|
||||||
return ProjectSalaryDetail::where($this->searchWhere)->count();
|
$prarms = $this->request->get(['payment_code','project_name','project_code']);
|
||||||
|
$where = [];
|
||||||
|
if(isset($prarms['payment_code']) && $prarms['payment_code'] != ''){
|
||||||
|
$salary_payment_ids = ProjectSalaryPayment::where('payment_code','like','%'.$prarms['payment_code'].'%')->column('id');
|
||||||
|
$where[] = ['salary_payment_id','in',$salary_payment_ids];
|
||||||
|
}
|
||||||
|
if(isset($prarms['project_name']) && $prarms['project_name'] != ''){
|
||||||
|
$project_ids = Project::where('name','like','%'.$prarms['project_name'].'%')->column('id');
|
||||||
|
$salary_payment_ids = ProjectSalaryPayment::where('project_id','in',$project_ids)->column('id');
|
||||||
|
$where[] = ['salary_payment_id','in',$salary_payment_ids];
|
||||||
|
}
|
||||||
|
if(isset($prarms['project_code']) && $prarms['project_code'] != ''){
|
||||||
|
$project_ids = Project::where('name','like','%'.$prarms['project_code'].'%')->column('id');
|
||||||
|
$salary_payment_ids = ProjectSalaryPayment::where('project_id','in',$project_ids)->column('id');
|
||||||
|
$where[] = ['salary_payment_id','in',$salary_payment_ids];
|
||||||
|
}
|
||||||
|
return ProjectSalaryDetail::where($this->searchWhere)->where($where)->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -46,7 +46,6 @@ class ProjectSalaryPaymentLogic extends BaseLogic
|
|||||||
{
|
{
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
$payment_detail = $params['payment_detail'];//json_decode($params['payment_detail'],true);
|
|
||||||
$res = ProjectSalaryPayment::create([
|
$res = ProjectSalaryPayment::create([
|
||||||
'payment_code' => data_unique_code('项目工资付款单'),
|
'payment_code' => data_unique_code('项目工资付款单'),
|
||||||
'project_id' => $params['project_id'],
|
'project_id' => $params['project_id'],
|
||||||
@ -55,7 +54,7 @@ class ProjectSalaryPaymentLogic extends BaseLogic
|
|||||||
'remark' => $params['remark'] ?? '',
|
'remark' => $params['remark'] ?? '',
|
||||||
'annex' => $params['annex']? json_encode($params['annex']) : null,
|
'annex' => $params['annex']? json_encode($params['annex']) : null,
|
||||||
]);
|
]);
|
||||||
foreach($payment_detail as $v){
|
foreach($params['payment_detail'] as $v){
|
||||||
ProjectSalaryDetail::create([
|
ProjectSalaryDetail::create([
|
||||||
'salary_payment_id' => $res->id,
|
'salary_payment_id' => $res->id,
|
||||||
'person_id' => $v['person_id'],
|
'person_id' => $v['person_id'],
|
||||||
@ -73,6 +72,47 @@ class ProjectSalaryPaymentLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function edit(array $params): bool
|
||||||
|
{
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
ProjectSalaryPayment::where('id', $params['id'])->update([
|
||||||
|
'project_id' => $params['project_id'],
|
||||||
|
'payment_type' => $params['payment_type'],
|
||||||
|
'apply_date' => strtotime($params['apply_date']),
|
||||||
|
'remark' => $params['remark'] ?? '',
|
||||||
|
'annex' => $params['annex']? json_encode($params['annex']) : null,
|
||||||
|
'update_time' => time(),
|
||||||
|
]);
|
||||||
|
foreach($params['payment_detail'] as $v){
|
||||||
|
if(isset($v['id']) && $v['id'] != ''){
|
||||||
|
ProjectSalaryDetail::where('id',$v['id'])->update([
|
||||||
|
'salary_payment_id' => $params['id'],
|
||||||
|
'person_id' => $v['person_id'],
|
||||||
|
'apply_date' => strtotime($params['apply_date']),
|
||||||
|
'apply_amount' => $v['apply_amount'],
|
||||||
|
'remark' => $v['remark'] ?? '',
|
||||||
|
'update_time' => time(),
|
||||||
|
]);
|
||||||
|
}else{
|
||||||
|
ProjectSalaryDetail::create([
|
||||||
|
'salary_payment_id' => $params['id'],
|
||||||
|
'person_id' => $v['person_id'],
|
||||||
|
'apply_date' => strtotime($params['apply_date']),
|
||||||
|
'apply_amount' => $v['apply_amount'],
|
||||||
|
'remark' => $v['remark'] ?? '',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
self::setError($e->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @notes 获取工资付款详情
|
* @notes 获取工资付款详情
|
||||||
@ -83,39 +123,12 @@ class ProjectSalaryPaymentLogic extends BaseLogic
|
|||||||
*/
|
*/
|
||||||
public static function detail($params): array
|
public static function detail($params): array
|
||||||
{
|
{
|
||||||
$data = ProjectSalaryPayment::field('id,payment_code,project_id,payment_type,apply_date,remark,annex')->findOrEmpty($params['id'])->toArray();
|
$data = ProjectSalaryPayment::field('id,payment_code,project_id,payment_type,apply_date,remark,annex')->findOrEmpty($params['id']);
|
||||||
$project = Project::field('name,project_code')->where('id',$data['project_id'])->findOrEmpty();
|
$project = Project::field('name,project_code')->where('id',$data['project_id'])->findOrEmpty();
|
||||||
$data['project_name'] = $project['name'];
|
$data['project_name'] = $project['name'];
|
||||||
$data['project_code'] = $project['project_code'];
|
$data['project_code'] = $project['project_code'];
|
||||||
//总工资付款
|
//总工资付款
|
||||||
$data['total_amount'] = ProjectSalaryDetail::where('salary_payment_id',$data['id'])->sum('apply_amount');
|
$data['total_amount'] = ProjectSalaryDetail::where('salary_payment_id',$data['id'])->sum('apply_amount');
|
||||||
$data['payment_detail'] = ProjectSalaryDetail::field('person_id,apply_amount,remark')->where('salary_payment_id',$data['id'])
|
return $data->toArray();
|
||||||
->select()->each(function($item){
|
|
||||||
$person = ProjectPersonnel::field('name,idcard,work_type,deposit_bank,bank_no')->where('id',$item['person_id'])->findOrEmpty();
|
|
||||||
$item['person_name'] = $person['name'];
|
|
||||||
$item['person_idcard'] = $person['idcard'];
|
|
||||||
$item['person_work_type_text'] = $person->work_type_text;
|
|
||||||
$item['person_deposit_bank'] = $person['deposit_bank'];
|
|
||||||
$item['person_bank_no'] = $person['bank_no'];
|
|
||||||
//总考勤收入
|
|
||||||
$daily_income = ProjectAttendanceDetail::where('person_id',$item['person_id'])->sum('daily_income');
|
|
||||||
//总施工收入
|
|
||||||
$build_report_details = BuildReportDetail::field('report_id,work_num')->where('person_id',$item['person_id'])->select()->each(function($item2){
|
|
||||||
$report = BuildReport::field('plan_id')->where('id',$item2['report_id'])->findOrEmpty();
|
|
||||||
$plan = BuildPlan::field('price')->where('id',$report['plan_id'])->findOrEmpty();
|
|
||||||
$item2['amount'] = $item2['work_num'] * $plan['price'];
|
|
||||||
})->toArray();
|
|
||||||
$work_income = 0;
|
|
||||||
foreach($build_report_details as $v){
|
|
||||||
$work_income += $v['amount'];
|
|
||||||
}
|
|
||||||
$item['total_income'] = $daily_income + $work_income;
|
|
||||||
//总支出
|
|
||||||
$item['total_pay_out'] = ProjectSalaryDetail::where('person_id',$item['person_id'])->sum('apply_amount');
|
|
||||||
$item['balance'] = $item['total_income'] - $item['total_pay_out'];
|
|
||||||
return $item;
|
|
||||||
})
|
|
||||||
->toArray();
|
|
||||||
return $data;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -18,6 +18,7 @@ namespace app\adminapi\validate\project;
|
|||||||
use app\common\model\dict\DictData;
|
use app\common\model\dict\DictData;
|
||||||
use app\common\model\project\Project;
|
use app\common\model\project\Project;
|
||||||
use app\common\model\project\ProjectPersonnel;
|
use app\common\model\project\ProjectPersonnel;
|
||||||
|
use app\common\model\project\ProjectSalaryDetail;
|
||||||
use app\common\validate\BaseValidate;
|
use app\common\validate\BaseValidate;
|
||||||
|
|
||||||
|
|
||||||
@ -131,6 +132,12 @@ class ProjectSalaryPaymentValidate extends BaseValidate
|
|||||||
return '工资支付明细数据格式错误';
|
return '工资支付明细数据格式错误';
|
||||||
}
|
}
|
||||||
foreach($payment_detail as $v) {
|
foreach($payment_detail as $v) {
|
||||||
|
if(isset($v['id']) && $v['id'] != ''){
|
||||||
|
$info = ProjectSalaryDetail::where('id',$v['id'])->findOrEmpty();
|
||||||
|
if($info->isEmpty()){
|
||||||
|
return '工资支付明细信息不存在';
|
||||||
|
}
|
||||||
|
}
|
||||||
if(empty($v['person_id'])){
|
if(empty($v['person_id'])){
|
||||||
return '请选择项目人员';
|
return '请选择项目人员';
|
||||||
}else{
|
}else{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user