feat(工资): 添加已发字段 修改状态描述
parent
b8ebcd8b5e
commit
5c7d421225
|
@ -573,6 +573,8 @@ class Manager extends Base
|
|||
$status = input('status/d', -1);
|
||||
$date = input('date/s', '');
|
||||
|
||||
$status = $status ?: -1;
|
||||
|
||||
$accountId = $this->request->user['user_id'] ?? 0;
|
||||
|
||||
$where = [];
|
||||
|
@ -605,16 +607,14 @@ class Manager extends Base
|
|||
->where($where);
|
||||
// 汇总信息
|
||||
$info = $query->fieldRaw('sum(pml.amount) as amount, sum(pml.base_amount) as base_amount,
|
||||
sum(pml.overtime_amount) as overtime_amount')->find()->toArray();
|
||||
// 已发放工资
|
||||
$doneAmount = $query->where('pml.status', 1)->fieldRaw('sum(pml.amount) as amount')->find()->toArray();
|
||||
sum(pml.overtime_amount) as overtime_amount,sum(pml.paid_amount) as paid_amount')->find()->toArray();
|
||||
|
||||
$res['info'] = [
|
||||
'amount' => $info['amount'] ?? 0,
|
||||
'base_amount' => $info['base_amount'] ?? 0,
|
||||
'overtime_amount' => $info['overtime_amount'] ?? 0,
|
||||
'done_amount' => $doneAmount['amount'] ?? 0,
|
||||
'not_amount' => Math::sub($info['amount'] ?? 0, $doneAmount['amount'] ?? 0),
|
||||
'done_amount' => $info['paid_amount'] ?? 0,
|
||||
'not_amount' => Math::sub($info['amount'] ?? 0, $info['paid_amount'] ?? 0),
|
||||
];
|
||||
|
||||
if ($status >= 0) {
|
||||
|
@ -629,9 +629,20 @@ class Manager extends Base
|
|||
$res['total'] = $total;
|
||||
|
||||
if ($total > 0) {
|
||||
$res['list'] = $query->field('pml.id,pml.status,pml.amount,pml.base_amount,pml.overtime_amount,a.real_name as name')->page($page, $size)->order('pml.id', 'desc')->select();
|
||||
$res['list'] = $query->field('pml.id,pml.status,pml.amount,pml.base_amount,pml.overtime_amount,pml.paid_amount,a.real_name as name')->page($page, $size)->order('pml.id', 'desc')->select();
|
||||
$res['list']->each(function ($item) {
|
||||
$item->status_text = $item->status == 1 ? '已发放' : '待发放';
|
||||
$item->status = 0;
|
||||
$item->status_text = '待发放';
|
||||
|
||||
if ($item['amount'] == $item['paid_amount'] && $item['amount'] > 0) {
|
||||
$item->status_text = '完全发放';
|
||||
$item->status = 1;
|
||||
}
|
||||
|
||||
if ($item['amount'] > $item['paid_amount'] && $item['paid_amount'] > 0) {
|
||||
$item->status_text = '部分发放';
|
||||
$item->status = 2;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -175,8 +175,8 @@ class Worker extends Base
|
|||
$arr = explode('-', $params['value']);
|
||||
$customer->save([
|
||||
'province' => $arr[0] ?? '',
|
||||
'city' => $arr[1] ?? '',
|
||||
'area' => $arr[2] ?? '',
|
||||
'city' => $arr[1] ?? '',
|
||||
'area' => $arr[2] ?? '',
|
||||
]);
|
||||
} else {
|
||||
$customer->save([
|
||||
|
@ -564,7 +564,7 @@ class Worker extends Base
|
|||
->leftJoin('account a', 'a.id = pml.account_id')
|
||||
->where($where)
|
||||
->group('pml.time')
|
||||
->fieldRaw('pml.time,pml.year,pml.month,sum(pml.amount) as amount,sum(pml.base_amount) as base_amount,sum(pml.overtime_amount) as overtime_amount');
|
||||
->fieldRaw('pml.time,pml.year,pml.month,sum(pml.amount) as amount,sum(pml.base_amount) as base_amount,sum(pml.overtime_amount) as overtime_amount,sum(pml.paid_amount) as paid_amount');
|
||||
|
||||
$total = $query->count();
|
||||
|
||||
|
@ -576,30 +576,21 @@ class Worker extends Base
|
|||
];
|
||||
|
||||
if ($total > 0) {
|
||||
// 获取按月已发工资
|
||||
$paidMonth = \app\model\PayMonthLog::alias('pml')
|
||||
->leftJoin('account a', 'a.id = pml.account_id')
|
||||
->where($where)
|
||||
->where('pml.status', 1)
|
||||
->group('pml.time')
|
||||
->page($page, $size)
|
||||
->order('time', 'desc')
|
||||
->fieldRaw('sum(pml.amount) as amount,pml.time')
|
||||
->select()->toArray();
|
||||
$monthPay = [];
|
||||
foreach ($paidMonth as $p) {
|
||||
$monthPay[$p['time']] = $p['amount'];
|
||||
}
|
||||
|
||||
$res['list'] = $query->page($page, $size)->order('time', 'desc')->select();
|
||||
$res['list']->each(function ($item) use ($monthPay) {
|
||||
$item->date = $item['year'].'年'.$item['month'].'月';
|
||||
$item->done = $monthPay[$item->time] ?? 0;
|
||||
$res['list']->each(function ($item) {
|
||||
$item->date = $item['year'].'年'.$item['month'].'月';
|
||||
// $item->done = $monthPay[$item->time] ?? 0;
|
||||
$item->status = 0;
|
||||
$item->status_text = '待发放';
|
||||
if ($item->amount <= $item->done) {
|
||||
|
||||
if ($item['amount'] == $item['paid_amount'] && $item['amount'] > 0) {
|
||||
$item->status_text = '完全发放';
|
||||
$item->status = 1;
|
||||
$item->status_text = '已发放';
|
||||
}
|
||||
|
||||
if ($item['amount'] > $item['paid_amount'] && $item['paid_amount'] > 0) {
|
||||
$item->status_text = '部分发放';
|
||||
$item->status = 2;
|
||||
}
|
||||
unset($item->year);
|
||||
unset($item->month);
|
||||
|
|
|
@ -281,6 +281,7 @@ class Pay extends Base
|
|||
->page($page, $size)->order('pml.time', 'desc')->order('pml.id', 'desc')->select();
|
||||
$res['list']->each(function ($item) {
|
||||
$item->status_text = '待发放';
|
||||
|
||||
if ($item['amount'] == $item['paid_amount'] && $item['amount'] > 0) {
|
||||
$item->status_text = '完全发放';
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue