|
@@ -13,6 +13,7 @@ use app\api\model\BrandModel;
|
|
use app\api\model\GroupModel;
|
|
use app\api\model\GroupModel;
|
|
use app\api\model\StaffModel;
|
|
use app\api\model\StaffModel;
|
|
use app\common\until\Until;
|
|
use app\common\until\Until;
|
|
|
|
+use think\Model;
|
|
|
|
|
|
class Staff extends BaseController {
|
|
class Staff extends BaseController {
|
|
|
|
|
|
@@ -56,17 +57,17 @@ class Staff extends BaseController {
|
|
}
|
|
}
|
|
|
|
|
|
if (!empty($input['storeId'])) {
|
|
if (!empty($input['storeId'])) {
|
|
- $arr = explode(',',$input['storeId']);
|
|
|
|
|
|
+ $arr = explode(',', $input['storeId']);
|
|
$where[] = ['s.store_id', 'in', $arr];
|
|
$where[] = ['s.store_id', 'in', $arr];
|
|
}
|
|
}
|
|
|
|
|
|
if (!empty($input['groupId'])) {
|
|
if (!empty($input['groupId'])) {
|
|
- $arr = explode(',',$input['groupId']);
|
|
|
|
|
|
+ $arr = explode(',', $input['groupId']);
|
|
$where[] = ['sto.group_id', 'in', $arr];
|
|
$where[] = ['sto.group_id', 'in', $arr];
|
|
}
|
|
}
|
|
|
|
|
|
if ($this->isAdmin()) {
|
|
if ($this->isAdmin()) {
|
|
- $where[] = ['gr.admin_id','=',$this->adminId];
|
|
|
|
|
|
+ $where[] = ['gr.admin_id', '=', $this->adminId];
|
|
}
|
|
}
|
|
$model->setWhere($where);
|
|
$model->setWhere($where);
|
|
$data = $model->getStaffList();
|
|
$data = $model->getStaffList();
|
|
@@ -88,6 +89,7 @@ class Staff extends BaseController {
|
|
* @OA\Property(description="职员手机号", property="mobile", type="string", default="12367897654"),
|
|
* @OA\Property(description="职员手机号", property="mobile", type="string", default="12367897654"),
|
|
* @OA\Property(description="入职日期", property="joinTime", type="string", default="2020-01-04"),
|
|
* @OA\Property(description="入职日期", property="joinTime", type="string", default="2020-01-04"),
|
|
* @OA\Property(description="职称id", property="staffTitleId", type="integer", default="1"),
|
|
* @OA\Property(description="职称id", property="staffTitleId", type="integer", default="1"),
|
|
|
|
+ * @OA\Property(description="性别", property="sex", type="integer", default="1男 2女"),
|
|
* @OA\Property(description="storeId", property="storeId", type="integer", default="1"),
|
|
* @OA\Property(description="storeId", property="storeId", type="integer", default="1"),
|
|
* required={"name","code","mobile","joinTime","staffTitleId","storeId"})
|
|
* required={"name","code","mobile","joinTime","staffTitleId","storeId"})
|
|
* )
|
|
* )
|
|
@@ -103,12 +105,13 @@ class Staff extends BaseController {
|
|
'mobile|职员手机号' => 'require',
|
|
'mobile|职员手机号' => 'require',
|
|
'joinTime|入职日期' => 'require',
|
|
'joinTime|入职日期' => 'require',
|
|
'staffTitleId|职称id' => 'require',
|
|
'staffTitleId|职称id' => 'require',
|
|
- 'storeId|storeId' => 'require',
|
|
|
|
|
|
+ 'storeId|storeId' => 'require',
|
|
|
|
+ 'sex|性别' => 'require|in:1,2',
|
|
];
|
|
];
|
|
Until::check($rule, $input);
|
|
Until::check($rule, $input);
|
|
$model = new StaffModel();
|
|
$model = new StaffModel();
|
|
if (!empty($input['id'])) {
|
|
if (!empty($input['id'])) {
|
|
- $rs = $model::where([['staff_code','=',$input['code']],['id','<>',$input['id']]])->find();
|
|
|
|
|
|
+ $rs = $model::where([['staff_code', '=', $input['code']], ['id', '<>', $input['id']]])->find();
|
|
if (!empty($rs)) {
|
|
if (!empty($rs)) {
|
|
throw new ApiException('工号不可重复');
|
|
throw new ApiException('工号不可重复');
|
|
}
|
|
}
|
|
@@ -120,10 +123,11 @@ class Staff extends BaseController {
|
|
'join_time' => $input['joinTime'],
|
|
'join_time' => $input['joinTime'],
|
|
'staff_title_id' => $input['staffTitleId'],
|
|
'staff_title_id' => $input['staffTitleId'],
|
|
'store_id' => $input['storeId'],
|
|
'store_id' => $input['storeId'],
|
|
|
|
+ 'sex' => $input['sex'],
|
|
'status' => $input['status'] ?? $model::NORMAL
|
|
'status' => $input['status'] ?? $model::NORMAL
|
|
]);
|
|
]);
|
|
} else {
|
|
} else {
|
|
- $rs = $model::where([['staff_code','=',$input['code']]])->find();
|
|
|
|
|
|
+ $rs = $model::where([['staff_code', '=', $input['code']]])->find();
|
|
if (!empty($rs)) {
|
|
if (!empty($rs)) {
|
|
throw new ApiException('工号不可重复');
|
|
throw new ApiException('工号不可重复');
|
|
}
|
|
}
|
|
@@ -133,7 +137,8 @@ class Staff extends BaseController {
|
|
'mobile' => $input['mobile'],
|
|
'mobile' => $input['mobile'],
|
|
'join_time' => $input['joinTime'],
|
|
'join_time' => $input['joinTime'],
|
|
'staff_title_id' => $input['staffTitleId'],
|
|
'staff_title_id' => $input['staffTitleId'],
|
|
- 'store_id' => $input['storeId']
|
|
|
|
|
|
+ 'store_id' => $input['storeId'],
|
|
|
|
+ 'sex' => $input['sex'],
|
|
]);
|
|
]);
|
|
}
|
|
}
|
|
$where[] = ['s.id', '=', (int)$id];
|
|
$where[] = ['s.id', '=', (int)$id];
|
|
@@ -173,7 +178,31 @@ class Staff extends BaseController {
|
|
* @OA\Response(response="200", description="请求成功")
|
|
* @OA\Response(response="200", description="请求成功")
|
|
* )
|
|
* )
|
|
*/
|
|
*/
|
|
- public function delete($id,$status) {
|
|
|
|
|
|
+ public function delete($id, $status) {
|
|
|
|
+ $model = new StaffModel();
|
|
|
|
+ $where[] = ['id', '=', (int)$id];
|
|
|
|
+ $data = ['status' => (int)$status];
|
|
|
|
+ $isSuccess = $model::where($where)->update($data);
|
|
|
|
+ Until::output(['isSuccess' => $isSuccess]);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @OA\GET(path="/api/Staff/turnStaffList",
|
|
|
|
+ * tags={"职员管理"},
|
|
|
|
+ * summary="获取排班职员列表",
|
|
|
|
+ * @OA\Parameter(name="token", in="header", description="token", @OA\Schema(type="string")),
|
|
|
|
+ * @OA\Parameter(name="storeId", in="query", description="门店id", @OA\Schema(type="ineger",default="1")),
|
|
|
|
+ * @OA\RequestBody(
|
|
|
|
+ * ),
|
|
|
|
+ * @OA\Response(response="200", description="请求成功")
|
|
|
|
+ * )
|
|
|
|
+ */
|
|
|
|
+ public function turnStaffList($id, $status) {
|
|
|
|
+ $input = Until::getInput();
|
|
|
|
+ $rule = [
|
|
|
|
+ 'storeId|storeId' => 'require',
|
|
|
|
+ ];
|
|
|
|
+ Until::check($rule, $input);
|
|
$model = new StaffModel();
|
|
$model = new StaffModel();
|
|
$where[] = ['id', '=', (int)$id];
|
|
$where[] = ['id', '=', (int)$id];
|
|
$data = ['status' => (int)$status];
|
|
$data = ['status' => (int)$status];
|