feature: 添加工资表
This commit is contained in:
parent
186fbca2d1
commit
665d273459
|
|
@ -79,9 +79,18 @@ class CustomDetail extends Backend
|
||||||
$res = [];
|
$res = [];
|
||||||
|
|
||||||
if (!$this->auth->check('salary/custom_detail/edit')) {
|
if (!$this->auth->check('salary/custom_detail/edit')) {
|
||||||
$admins = Db::name('admin')->where('id', $this->auth->id)->field('id,nickname')->select();
|
$admins = Db::name('admin a')
|
||||||
|
->join('fa_salary_status ss', 'a.id = fa_salary_status.target_admin_id')
|
||||||
|
->where('create_status', 1)
|
||||||
|
->where('salary_month', '=', $month)
|
||||||
|
->where('admin.id', $this->auth->id)
|
||||||
|
->field('a.id,a.nickname,ss.settle_status')->select();
|
||||||
} else{
|
} else{
|
||||||
$admins = Db::name('admin')->field('id,nickname')->select();
|
$admins = Db::name('admin a')
|
||||||
|
->join('fa_salary_status ss', 'a.id = fa_salary_status.target_admin_id')
|
||||||
|
->where('create_status', 1)
|
||||||
|
->where('salary_month', '=', $month)
|
||||||
|
->field('a.id,a.nickname,ss.settle_status')->select();
|
||||||
}
|
}
|
||||||
|
|
||||||
$admins = array_column($admins, NULL, 'id');
|
$admins = array_column($admins, NULL, 'id');
|
||||||
|
|
@ -103,18 +112,6 @@ class CustomDetail extends Backend
|
||||||
$queryRes[$targetAdminId][$itemId] = $queryDatum['item_value'];
|
$queryRes[$targetAdminId][$itemId] = $queryDatum['item_value'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$querySettleData = Db::name('salary_settle')
|
|
||||||
->whereIn('target_admin_id', $adminIds)
|
|
||||||
->where('salary_month', '=', $month)
|
|
||||||
->field('id,target_admin_id,settle_status')
|
|
||||||
->select();
|
|
||||||
$querySettleRes = [];
|
|
||||||
foreach ($querySettleData as $querySettleDatum) {
|
|
||||||
$targetAdminId = $querySettleDatum['target_admin_id'];
|
|
||||||
$querySettleRes[$targetAdminId] = $querySettleDatum['settle_status'];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
foreach ($adminIds as $adminId) {
|
foreach ($adminIds as $adminId) {
|
||||||
$attrValue = [];
|
$attrValue = [];
|
||||||
$total = 0;
|
$total = 0;
|
||||||
|
|
@ -143,7 +140,7 @@ class CustomDetail extends Backend
|
||||||
$jxTotal = ($attrValue['ZWJX'] - $attrValue['YYCB']) * $attrValue['TD'] / 100;
|
$jxTotal = ($attrValue['ZWJX'] - $attrValue['YYCB']) * $attrValue['TD'] / 100;
|
||||||
$res[$adminId]['jx_total'] = $this->clean_number($jxTotal);
|
$res[$adminId]['jx_total'] = $this->clean_number($jxTotal);
|
||||||
$res[$adminId]['total'] = $this->clean_number($total + $jxTotal);
|
$res[$adminId]['total'] = $this->clean_number($total + $jxTotal);
|
||||||
$res[$adminId]['settle_status'] = $querySettleRes[$adminId] ?? 0;
|
$res[$adminId]['settle_status'] = $admins[$adminId]['settle_status'] ?? 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = array_values($res);
|
$res = array_values($res);
|
||||||
|
|
@ -229,6 +226,14 @@ class CustomDetail extends Backend
|
||||||
Db::name('salary_detail')
|
Db::name('salary_detail')
|
||||||
->insertAll($salaryDetails);
|
->insertAll($salaryDetails);
|
||||||
|
|
||||||
|
|
||||||
|
Db::name('salary_status')->insert([
|
||||||
|
'target_admin_id' => $targetAdminId,
|
||||||
|
'salary_month' => $month,
|
||||||
|
'settle_status' => 0,
|
||||||
|
'create_status' => 1,
|
||||||
|
]);
|
||||||
|
|
||||||
$this->success();
|
$this->success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -320,12 +325,12 @@ class CustomDetail extends Backend
|
||||||
$month = $this->request->get('month');
|
$month = $this->request->get('month');
|
||||||
|
|
||||||
|
|
||||||
$settle = Db::name('salary_settle')
|
$settle = Db::name('salary_status')
|
||||||
->where('salary_month', $month)
|
->where('salary_month', $month)
|
||||||
->where('target_admin_id', $targetAdminId)
|
->where('target_admin_id', $targetAdminId)
|
||||||
->field('target_admin_id,salary_month')->find();
|
->field('target_admin_id,salary_month')->find();
|
||||||
if (!empty($settle)) {
|
if (!empty($settle)) {
|
||||||
Db::name('salary_settle')
|
Db::name('salary_status')
|
||||||
->where('salary_month', $month)
|
->where('salary_month', $month)
|
||||||
->where('target_admin_id', $targetAdminId)
|
->where('target_admin_id', $targetAdminId)
|
||||||
->save([
|
->save([
|
||||||
|
|
@ -334,7 +339,7 @@ class CustomDetail extends Backend
|
||||||
$this->success();
|
$this->success();
|
||||||
}
|
}
|
||||||
|
|
||||||
Db::name('salary_settle')->insert([
|
Db::name('salary_status')->insert([
|
||||||
'target_admin_id' => $targetAdminId,
|
'target_admin_id' => $targetAdminId,
|
||||||
'salary_month' => $month,
|
'salary_month' => $month,
|
||||||
'settle_status' => 1,
|
'settle_status' => 1,
|
||||||
|
|
|
||||||
|
|
@ -52,38 +52,6 @@ class Detail extends Backend
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function settle()
|
|
||||||
{
|
|
||||||
if (false === $this->request->isPost()) {
|
|
||||||
$this->error(__("Invalid parameters"));
|
|
||||||
}
|
|
||||||
|
|
||||||
$targetAdminId = $this->request->get('target_admin_id');
|
|
||||||
$month = $this->request->get('month');
|
|
||||||
|
|
||||||
|
|
||||||
$settle = Db::name('salary_settle')
|
|
||||||
->where('salary_month', $month)
|
|
||||||
->where('target_admin_id', $targetAdminId)
|
|
||||||
->field('target_admin_id,salary_month')->find();
|
|
||||||
if (!empty($settle)) {
|
|
||||||
Db::name('salary_settle')
|
|
||||||
->where('salary_month', $month)
|
|
||||||
->where('target_admin_id', $targetAdminId)
|
|
||||||
->save([
|
|
||||||
'settle_status' => 1,
|
|
||||||
]);
|
|
||||||
$this->success();
|
|
||||||
}
|
|
||||||
|
|
||||||
Db::name('salary_settle')->insert([
|
|
||||||
'target_admin_id' => $targetAdminId,
|
|
||||||
'salary_month' => $month,
|
|
||||||
'settle_status' => 1,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$this->success();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user