Merge branch 'master' of 47.101.48.251:/data/git/bd-fangke

master
lion 3 years ago
commit 4c066f1ad4

@ -128,9 +128,15 @@ class GateController extends CommonController
if ($all['type'] == 2) {
$remark = '离厂';
}
$gateLog = GateLog::add($all['admin_id'], $all['code'], $all['person_no']??[], $all['car_no']??[], $remark);
$gateLog = GateLog::add($all['admin_id'], $all['code'], $all['person_no'] ?? [], $all['car_no'] ?? [], $remark);
if ($all['type'] == 1) {
Visit::where('code', $all['code'])->update(['audit_status' => 3, 'person_no' => $all['person_no']??'', 'car_no' => $all['car_no']??'']);
// 入场
Visit::where('code', $all['code'])->update(['audit_status' => 3, 'person_no' => $all['person_no'] ?? '', 'car_no' => $all['car_no'] ?? '']);
// 通知被访人
$vars = ['date' => $check->date, 'name' => $check->name, 'phone_number' => $check->mobile];
$template_id = 'zPtka4';
$acceptAdmin = Admin::find($check->accept_admin_id);
sms($acceptAdmin->mobile, $vars, $template_id);
}
if ($all['type'] == 2) {
Visit::where('code', $all['code'])->update(['audit_status' => 4]);

@ -20,6 +20,7 @@ class OtherController extends CommonController
* @OA\Parameter(name="sort_type", in="query", @OA\Schema(type="string"), required=false, description="排序类型"),
* @OA\Parameter(name="department_id", in="query", @OA\Schema(type="int"), required=false, description="部门id"),
* @OA\Parameter(name="keyword", in="query", @OA\Schema(type="string"), required=false, description="关键词"),
* @OA\Parameter(name="show_all", in="query", @OA\Schema(type="string"), required=false, description="是否显示全部0否1是"),
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
* @OA\Response(
* response="200",
@ -30,15 +31,18 @@ class OtherController extends CommonController
public function adminUserList()
{
$all = \request()->all();
$list = Admin::where(function ($query) use ($all){
if(isset($all['department_id'])){
$query->where('department_id',$all['department_id']);
$show_all = request('show_all', 0);
$list = Admin::where(function ($query) use ($all, $show_all) {
if (isset($all['department_id'])) {
$query->where('department_id', $all['department_id']);
}
if(isset($all['keyword'])){
$query->where('name',$all['keyword'])->orWhere('mobile',$all['keyword']);
if (isset($all['keyword'])) {
$query->where('name', $all['keyword'])->orWhere('mobile', $all['keyword']);
} else {
if (empty($show_all)) $query->where('id', -1);
}
})->orderBy($all['sort_name']??'id',$all['sort_type']??'desc')
->paginate($all['page_size']??20);
})->orderBy($all['sort_name'] ?? 'id', $all['sort_type'] ?? 'desc')
->paginate($all['page_size'] ?? 20);
return $this->success($list);
}
@ -64,16 +68,16 @@ class OtherController extends CommonController
public function adminDepartmentList()
{
$all = \request()->all();
$list = Department::with('users')->where(function ($query) use ($all){
if(isset($all['keyword'])){
$query->where('name','like','%'.$all['keyword'].'%');
$list = Department::with('users')->where(function ($query) use ($all) {
if (isset($all['keyword'])) {
$query->where('name', 'like', '%' . $all['keyword'] . '%');
}
});
if(isset($all['show_tree']) && $all['show_tree']){
if (isset($all['show_tree']) && $all['show_tree']) {
// 显示树形结构
$list = array2tree($list->orderBy($all['sort_name']??'id',$all['sort_type']??'desc')->get()->toArray());
}else{
$list = $list->orderBy($all['sort_name']??'id',$all['sort_type']??'desc')->paginate($all['page_size']??20);
$list = array2tree($list->orderBy($all['sort_name'] ?? 'id', $all['sort_type'] ?? 'desc')->get()->toArray());
} else {
$list = $list->orderBy($all['sort_name'] ?? 'id', $all['sort_type'] ?? 'desc')->paginate($all['page_size'] ?? 20);
}
return $this->success($list);
}

@ -140,6 +140,10 @@ class VisitAuditController extends CommonController
$model->save();
// 获取必要数据
$visit = Visit::find($all['visit_id']);
// 短信通知下一个审核人,如果当前通过的话
if ($all['status'] == 1) {
VisitAudit::smsNextAudit($visit, $model->level);
}
$user = User::find($visit->user_id);
$visitTime = VisitTime::find($visit->visit_time_id);
$acceptAdmin = Admin::find($visit->accept_admin_id);
@ -165,25 +169,31 @@ class VisitAuditController extends CommonController
sms($acceptAdmin->mobile, $vars, $template_id);
}
}
// 发通知
$templateData = [
'date1' => [
'value' => $visit->date
],
'name3' => [
'value' => $acceptAdmin->name,
],
'thing4' => [
'value' => $visit->name
],
'thing13' => [
'value' => $auditResult,
],
'thing9' => [
'value' => $visit->company_name
],
];
Visit::subMsg('IczaKkCmwf55tAAzCcxb_fbbf5L25SWrSKvaBrkIyk4', $user->openid, $templateData,$all['visit_id']);
if ($auditResult) {
// 发通知订阅消息
$templateData = [
'date1' => [
'value' => $visit->date
],
'name3' => [
'value' => $acceptAdmin->name,
],
'thing4' => [
'value' => $visit->name
],
'thing13' => [
'value' => $auditResult,
],
'thing9' => [
'value' => $visit->company_name
],
];
Visit::subMsg('IczaKkCmwf55tAAzCcxb_fbbf5L25SWrSKvaBrkIyk4', $user->openid, $templateData, $all['visit_id']);
// 发通知短信消息
$vars = ['result' => $auditResult];
$template_id = 'G5W6Y3';
sms($visit->mobile, $vars, $template_id);
}
}
// 审核记录
$auditAdmin = Admin::find($model->audit_admin_id);

@ -125,8 +125,9 @@ class VisitController extends CommonController
}
}
VisitLog::add('', $this->getUser(), $model->id, isset($all['id']) ? '更新拜访记录' : '新增拜访记录');
// 通知
// 通知,发订阅消息给当前用户
$visitTime = VisitTime::find($all['visit_time_id']);
// 被访人信息
$acceptAdmin = Admin::find($all['accept_admin_id']);
$accpetDepartment = Department::find($all['accpet_department_id']);
$templateData = [
@ -146,7 +147,13 @@ class VisitController extends CommonController
'value' => $accpetDepartment->name ?? ''
],
];
$res = Visit::subMsg('DmzNRREPFdZrMWconNDdbj_ebtVPRWufq27kRQ25eNg', $this->getUser()->openid, $templateData, $model->id);
Visit::subMsg('DmzNRREPFdZrMWconNDdbj_ebtVPRWufq27kRQ25eNg', $this->getUser()->openid, $templateData, $model->id);
// 短信通知被访人
$vars = ['date' => $all['date'], 'name' => $all['name'], 'phone_number' => $all['mobile']];
$template_id = '5wReg1';
sms($acceptAdmin->mobile, $vars, $template_id);
// 短信通知第一个审核人
VisitAudit::smsNextAudit($model);
DB::commit();
return $this->success('更新成功');
} catch (\Exception $exception) {

@ -1,17 +1,46 @@
<?php
namespace App\Models;
class VisitAudit extends SoftDeletesModel
{
protected $guarded = ['id'];
protected $guarded = ['id'];
public function visit(){
return $this->hasOne(Visit::class,'id','visit_id');
}
public function visit()
{
return $this->hasOne(Visit::class, 'id', 'visit_id');
}
public function auditAdmin()
{
return $this->hasOne(Admin::class, 'id', 'audit_admin_id');
}
/**
* 短信通知下一个审核人
*/
public static function smsNextAudit($visit, $nowVisitAuditLevel = 0)
{
// 通知下一个审核人
$mobile = Admin::where(function ($query) use ($visit, $nowVisitAuditLevel) {
if ($nowVisitAuditLevel == 0) {
// 通知第一个审核人
$adminId = VisitAudit::where('visit_id', $visit->id)->orderBy('level', 'asc')->value('audit_admin_id');
} else {
$adminId = VisitAudit::where('visit_id', $visit->id)
->where('level', '>', $nowVisitAuditLevel)
->orderBy('level', 'asc')
->value('audit_admin_id');
}
$query->where('id', $adminId);
})->value('mobile');
if (empty($mobile)) {
return false;
}
$vars = ['date' => $visit->date, 'name' => $visit->name, 'phone_number' => $visit->mobile];
$template_id = 'uAQaB4';
sms($mobile, $vars, $template_id);
return true;
}
}

Loading…
Cancel
Save