feat(用户接口): 1.用户详情 2.用户评级列表

master
yin5th 2023-01-13 17:43:19 +08:00
parent 79ca610e57
commit 1cf835c2d7
6 changed files with 95 additions and 4 deletions

View File

@ -716,7 +716,7 @@ class Manager extends Base
return $this->json(4001, '参数错误');
}
if (!$account = Account::findById($accountId, ['id, role'])) {
if (!$account = Account::findById($accountId, ['id, role, worksite_id'])) {
return $this->json(6001, '请先登录');
}
@ -734,6 +734,7 @@ class Manager extends Base
'type' => AccountStar::TYPE_WORKER,
'star' => $star,
'account_id' => $id,
'worksite_id' => $account['worksite_id'],
'year' => date('Y'),
'month' => date('m'),
'ym' => $ym,

View File

@ -7,6 +7,7 @@ use app\exception\ApiException;
use app\exception\RepositoryException;
use app\model\Account;
use app\model\AccountRecord;
use app\model\AccountStar;
use app\model\ClockLog;
use app\model\PayLog;
use app\model\Worksite;
@ -702,6 +703,80 @@ class User extends Base
return $this->json();
}
/**
* 评级列表
*
* @return \think\response\Json
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function starList(): Json
{
$accountId = $this->request->user['user_id'] ?? 0;
$worksiteId = input('worksite_id/d', 0);
$worksiteId = $worksiteId ?: 0;
if (!$account = Account::findById($accountId)) {
return $this->json(6001, '请先登录');
}
$where = [];
$where[] = ['account_id', '=', $accountId];
$worksiteId = $worksiteId ?: $account['worksite_id'];
$where[] = ['worksite_id', '=', $worksiteId];
$where[] = ['type', '=', AccountStar::TYPE_WORKER];
$list = \app\model\AccountStar::where($where)
->order('ym', 'desc')
->select();
$yearArr = $list->column('year');
$yearArr = array_unique($yearArr);
$starList = [];
foreach ($yearArr as $year) {
$starList[$year.'年'] = [];
}
foreach ($list as $val) {
$starList[$val['year'].'年'][] = [
'year' => $val['year'],
'month' => $val['month'],
'star' => $val['star'],
];
}
$firstStar = $list->first()['star'] ?? 0;
$info = [
'real_name' => $account['real_name'] ?? '',
'worksite_name' => Worksite::where('id', $account['worksite_id'])->value('name'),
'star' => $firstStar,
];
return $this->json(0, 'success', ['info' => $info, 'list' => $starList]);
}
/**
* 用户详情
*
* @return Json
*/
public function detail(): Json
{
try {
$accountId = input('id/d');
$user = Account::getUser($accountId);
return $this->json(0, 'success', $user);
} catch (Exception $e) {
return $this->json(4000, '获取用户详情失败'.$e->getMessage());
}
}
/**
* 普通用户打卡
*

View File

@ -217,10 +217,10 @@ class Pay extends Base
if ($total > 0) {
$res['list'] = $query->field('pml.id,sum(pml.amount) as amount,sum(pml.base_amount) as base_amount,pml.status,pml.year,pml.month,
sum(pml.overtime_amount) as overtime_amount,pml.account_id,pml.time,a.nickname,a.real_name,a.mobile,w.name as worksite_name,
p.name as position_text')
->page($page, $size)->order('pml.id', 'desc')->select();
p.name as position_text,pml.paid_amount')
->page($page, $size)->order('pml.time', 'desc')->order('pml.id', 'desc')->select();
$res['list']->each(function ($item) {
$item->status_text = $item->status == 1 ? '已发放' : '待发放';
$item->status_text = PayMonthLog::statusText()[$item->status] ?? '';
$item->time_text = $item->year.'年'.$item->month.'月';
});
}

View File

@ -13,6 +13,19 @@ use think\model\relation\HasOne;
*/
class PayMonthLog extends Base
{
public const STATUS_YES = 1;
public const STATUS_NO = 0;
public const STATUS_PART = 2;
public static function statusText(): array
{
return [
self::STATUS_YES => '已发放',
self::STATUS_NO => '待发放',
self::STATUS_PART => '部分发放',
];
}
public function account(): HasOne
{
return $this->hasOne(Account::class, 'id', 'account_id');

View File

@ -55,6 +55,7 @@ layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect', 'laydate'
{field: 'amount', minWidth: 100, title: '总计'},
{field: 'base_amount', minWidth: 100, title: '基本工资'},
{field: 'overtime_amount', minWidth: 100, title: '加班工资'},
{field: 'paid_amount', minWidth: 100, title: '已发工资'},
{field: 'status_text', minWidth: 100, title: '状态'},
{templet: '#row-operate', fixed: "right", minWidth: 100, title: '操作'},
]],

View File

@ -21,6 +21,7 @@
<select name="status">
<option value=""></option>
<option value="1">已发放</option>
<option value="2">部分发放</option>
<option value="0">待发放</option>
</select>
</div>