提交 999714a1 authored 作者: 李大见's avatar 李大见

批量审核20260311

上级 48af5e96
......@@ -2199,4 +2199,79 @@ class WashWorkController extends Controller
$return_data = WashWorkService::returnItemInfo($user_info, $request->all());
return response()->json($return_data);
}
// 审核工单列表
public function auditWorkIndex(Request $request)
{
// 记录日志
$log_record['request'] = $request->all();
$log_record['time'] = date('Y-m-d H:i:s');
$log_record['function'] = 'index';
logFileRecord($log_record, 'wash/WashWork', 2);
request()->offsetSet('rt', 'wechat');
$user_info = LoginUserService::getUser();
$list_button = getAppletListButton($request['api_token'], $request['pri_id']);
$search_data = $this->dataService->auditWorkIndex($user_info, $request->all(), 10);
// 获取当前列表下的按钮
$list_items = $search_data['data'];
if (!empty($list_items)) {
$search_data['data'] = $list_items;
}
return response()->json(['code'=>200, 'msg'=>'success', 'data'=>$search_data]);
}
// 小程序批量审核
public function batchAudit(Request $request) {
// 记录日志
$log_record['request'] = $request->all();
$log_record['time'] = date('Y-m-d H:i:s');
$log_record['function'] = 'index';
logFileRecord($log_record, 'wash/WashWork/batchAudit', 2);
request()->offsetSet('rt', 'wechat');
$user_info = LoginUserService::getUser();
$find_data = DB::table('work_order')
->whereIn('wor_id', $request['wor_id'])
->select('wor_state', 'wor_number', 'wor_order_number', 'wor_id')
->get();
foreach($find_data as $key => $value) {
if ($value->wor_state != 8) {
return response()->json(['code'=>500, 'msg'=>$value->wor_order_number.'不是待审核状态', 'data'=>$value->wor_order_number.'不是待审核状态']);
}
}
DB::beginTransaction();
foreach($find_data as $key1 => $value1) {
$add_data['wor_id'] = $value1->wor_id;
$add_data['wor_refuse_remark'] = '批量审核驳回';
$add_data['wor_refuse_data'] = '';
$add_data['type'] = 1;
$add_data['create_id'] = $user_info->adm_id;
$add_data['create_time'] = date('Y-m-d H:i:s');
$add_res = DB::table('work_refuse')->insertGetId($add_data);
}
if ($request['state'] == 1) {
$wor_edit_data['wor_service_state'] = 7;
$wor_edit_data['wor_state'] = 9;
$wor_edit_data['wor_update_time'] = date('Y-m-d H:i:s');
$wor_edit_res = DB::table('work_order')->whereIn('wor_id', $request['wor_id'])->update($wor_edit_data);
$content = '小程序批量施工审核[通过]';
} else {
$wor_edit_data['wor_service_state'] = 5;
$wor_edit_data['wor_state'] = 7;
$wor_edit_data['wor_update_time'] = date('Y-m-d H:i:s');
$wor_edit_res = DB::table('work_order')->whereIn('wor_id', $request['wor_id'])->update($wor_edit_data);
$content = '小程序批量施工审核[驳回]';
}
if (!$wor_edit_res) {
DB::rollBack();
return response()->json(['code'=>200, 'msg'=>'success', 'data'=>$search_data]);
}
foreach ($find_data as $key2 => $value2) {
$wor_order_id =DB::table('work_order')->where('wor_id', $value2->wor_id)->value('wor_order_id');
orderLog($user_info, $wor_order_id, $value2->wor_id, $content);
}
OperationLog::addLog($user_info, getRealIp($request), '工单列表', '小程序批量施工审核', $content);
DB::commit();
return response()->json(['code'=>200, 'msg'=>'操作成功', 'data'=>'操作成功']);
}
}
......@@ -134,7 +134,11 @@ class QualityTestingService extends Service
$data['qurp_standard'] = $request['qurp_standard'];//分数
} elseif ($request['qurp_type'] == 2 || $request['qurp_type'] == 3) {
$request['qurp_standard_type'] = 2;
$data['qurp_standard'] = $request['qurp_standard']*100;//标准金额(单位分)
if ($request['qurp_type'] == 2) {
$data['qurp_standard'] = abs($request['qurp_standard']*100);//标准金额(单位分)
} elseif ($request['qurp_type'] == 3) {//惩罚项 强制负值
$data['qurp_standard'] = -abs($request['qurp_standard']*100);
}
}
$data['qurp_standard_type'] = $request['qurp_standard_type'];//标准类型1分数2金额
$data['qurp_type'] = $request['qurp_type'];//类型1质检标准2奖励项3惩罚项
......@@ -156,7 +160,11 @@ class QualityTestingService extends Service
$data['qurp_standard'] = $request['qurp_standard'];//分数
} elseif ($request['qurp_type'] == 2 || $request['qurp_type'] == 3) {
$request['qurp_standard_type'] = 2;
$data['qurp_standard'] = $request['qurp_standard']*100;//标准金额(单位分)
if ($request['qurp_type'] == 2) {
$data['qurp_standard'] = abs($request['qurp_standard']*100);//标准金额(单位分)
} elseif ($request['qurp_type'] == 3) {//惩罚项 强制负值
$data['qurp_standard'] = -abs($request['qurp_standard']*100);
}
}
$data['qurp_standard_type'] = $request['qurp_standard_type'];//标准类型1分数2金额
$data['qurp_type'] = $request['qurp_type'];//类型1质检标准2奖励项3惩罚项
......
......@@ -8052,4 +8052,378 @@ class WashWorkService extends Service
return ['code'=>200, 'msg'=>'success', 'data'=>$return_data];
}
public function auditWorkIndex($user_info, $search_data, $show_count = 10)
{
$search_data['state'] = [5];
$search_data['wor_state'] = 8;
$adm_leave = DB::table('admin_shop_role')
->where('adm_id', $user_info->adm_id)
->where('shop_id', $user_info->adm_shop_id)
->value('adm_shop_leave as adm_leave');
$all_work = false;
if (isset($search_data['pri_id'])) {
$list_button = getAppletListButton($search_data['api_token'], $search_data['pri_id']);
foreach ($list_button as $key => $value) {
if ($value['pri_id'] == 79 && $value['have_pri'] == 1) {
$all_work = true;
}
}
$pri_id = array_column($list_button, 'pri_id');
}
// 筛选当前技师负责施工部位的工单
//区分是否为店长
// if($adm_leave == 1 || $all_work){
// $list_data = DB::table('work_order as b')
// ->leftJoin('shop as s', 's.shop_id', '=', 'b.wor_shop_id')
// ->leftJoin('order as o', 'o.ord_id', '=', 'b.wor_order_id')
// ->leftJoin('work_client as c', 'c.wocl_wor_id', '=', 'b.wor_id')
// ->leftJoin('order_client as oc', 'oc.orcl_ord_id', '=', 'b.wor_order_id')
// ->where('wor_shop_id', $user_info->adm_shop_id);
// }else{
// }
$list_data = DB::table('wash_work_technician_part as a')
->leftJoin('work_order as b', 'b.wor_id', '=', 'a.wotp_wor_id')
->leftJoin('shop as s', 's.shop_id', '=', 'b.wor_shop_id')
->leftJoin('order as o', 'o.ord_id', '=', 'b.wor_order_id')
->leftJoin('work_client as c', 'c.wocl_wor_id', '=', 'a.wotp_wor_id')
->leftJoin('order_client as oc', 'oc.orcl_ord_id', '=', 'b.wor_order_id')
->where('wotp_shop_id', $user_info->adm_shop_id)
->where(function ($query) use ($search_data) { //关键字搜索
if (!empty($search_data['wotp_service_adm_id'])) {
$query->where('wotp_service_adm_id', $search_data['wotp_service_adm_id']);
}
});
$list_data = $list_data->where('wor_delete', 1)
->where('wor_collection_bill', 1) //是否代收账单:1正常工单2代收账单
->where(function ($query) use ($search_data) { //关键字搜索
if (!empty($search_data['keywords'])) {
$query->where('wor_order_number', 'like', '%' . $search_data['keywords'] . '%')
->orwhere('wor_number', 'like', '%' . $search_data['keywords'] . '%')
->orwhere('wocl_phone', 'like', '%' . $search_data['keywords'] . '%')
->orwhere('wocl_car_num', 'like', '%' . $search_data['keywords'] . '%')
->orwhere('wocl_sales_adm_name', 'like', '%' . $search_data['keywords'] . '%')
->orwhere('wocl_name', 'like', '%' . $search_data['keywords'] . '%');
}
})
->where(function ($query) use ($search_data,$user_info) {
if (!empty($search_data['search_state'])) {
if ($search_data['search_state'] == 1) { //待接单列表
$query->where('wor_service_state', 1)
->where('wor_service_adm_id', $user_info->adm_id);
} elseif ($search_data['search_state'] == 2) { //待验车
$query->whereIn('wor_service_state', [3]);
} elseif ($search_data['search_state'] == 3) { //待施工
$query->where('wor_service_state', 4);
} elseif ($search_data['search_state'] == 4) { //施工中
$query->whereIn('wor_service_state', [5,6]);
} elseif ($search_data['search_state'] == 5) { //完成待审核
$query->whereIn('wor_service_state', [8]);
} elseif ($search_data['search_state'] == 6) { //待还件
$query->whereIn('wor_service_state', [7]);
}
}
})
->where(function ($query) use ($search_data) { //订单号
if (!empty($search_data['wor_order_number'])) {
$query->where('wor_order_number', 'like', '%' . $search_data['wor_order_number'] . '%');
}
})
->where(function ($query) use ($search_data) { //工单号
if (!empty($search_data['wor_number'])) {
$query->where('wor_number', 'like', '%' . $search_data['wor_number'] . '%');
}
})
->where(function ($query) use ($search_data) { //姓名
if (!empty($search_data['wocl_name'])) {
$query->where('wocl_name', 'like', '%' . $search_data['wocl_name'] . '%');
}
})
->where(function ($query) use ($search_data) { //联系电话
if (!empty($search_data['wocl_phone'])) {
$query->where('wocl_phone', 'like', '%' . $search_data['wocl_phone'] . '%');
}
})
->where(function ($query) use ($search_data) { //车牌号
if (!empty($search_data['wocl_car_num'])) {
$query->where('wocl_car_num', 'like', '%' . $search_data['wocl_car_num'] . '%');
}
})
->where(function ($query) use ($search_data) { //订单类型1会员零售2客户单位3速电派单
if (!empty($search_data['wor_type'])) {
$query->where('wor_type', $search_data['wor_type']);
}
})
->where(function ($query) use ($search_data) { //1.新订单 2未派单 3待接单/已派单 4.未出发/已接单 5.预约/已预约 6.出发/已出发 7.抵达/抵达 8.待审核/完成待审核 9驳回/完成已驳回 10完成/完成已通过 11终止 12锁定13.速电撤销回收
if (!empty($search_data['wor_state'])) {
$query->where('wor_state', $search_data['wor_state']);
}
})
->where(function ($query) use ($search_data) { //派单人
if (!empty($search_data['wor_create_id'])) {
$query->where('wor_create_id', $search_data['wor_create_id']);
}
})
->where(function ($query) use ($search_data) { //备注
if (!empty($search_data['wor_remark'])) {
$query->where('wor_remark', 'like', '%' . $search_data['wor_remark'] . '%');
}
})
->where(function ($query) use ($search_data) { //订单类型
if (!empty($search_data['wor_service_type'])) {
$query->where('wor_service_type', $search_data['wor_service_type']);
}
})
->where(function ($query) use ($search_data) { //智配审核结果:1未审核2通过3驳回
if (!empty($search_data['wor_other_audit'])) {
$query->where('wor_other_audit', $search_data['wor_other_audit'])
->where('wor_work_type', 2);
}
})
->where(function ($query) use ($search_data) { //创建时间/派单时间
// 如果选择开始时间并且选择结束时间
if (!empty($search_data['create_time_start']) && !empty($search_data['create_time_end'])) {
$query->whereBetween('wor_create_time', [$search_data['create_time_start'], $search_data['create_time_end'] . ' 23:59:59']);
} else {
// 如果选择开始时间
if (!empty($search_data['create_time_start'])) {
$query->where('wor_create_time', '>=', $search_data['create_time_start']);
} else {
// 如果选择结束时间
if (!empty($search_data['create_time_end'])) {
$query->where('wor_create_time', '<=', $search_data['create_time_end'] . ' 23:59:59');
}
}
}
})
->where(function ($query) use ($search_data) { //客户id/会员id
if (!empty($search_data['wocl_client_id'])) {
$query->where('wocl_client_id', $search_data['wocl_client_id']);
}
})
->where(function ($query) use ($search_data) { //是否验车
if (!empty($search_data['wocl_check_car_state'])) {
$query->where('wocl_check_car_state', $search_data['wocl_check_car_state']);
}
})
->select('wor_id', 'wor_number', 'wor_order_number', 'wor_shop_id', 'wor_create_id', 'wor_type', 'wor_state', 'wor_service_state', 'wor_appoint_time', 'wocl_appoint_remark', 'wocl_car_vehicle_type', 'wocl_pick_up_car_time', 'wocl_check_car_state', 'wocl_name', 'wocl_phone', 'wocl_car_num', 'wocl_car_vehicle_type', 'wocl_car_vin', 'wocl_car_brand_series', 'wor_province', 'wor_city', 'wor_county', 'wor_address', 'wocl_carowner_phone', 'wocl_carowner_name', 'wor_explain as wor_remark', 'wocl_bus_name', 'shop_store_name', 'wor_address_type', 'wor_address_id', 'wor_service_adm_id', 'wocl_carbrse_type', 'wor_work_type', 'wor_order_id', 'wocl_client_id', 'wor_list_pic', 'ord_new_type', 'ord_id', 'wor_create_time')
->orderBy('wor_appoint_time', 'desc')
->orderBy('wor_id', 'desc')
->groupBy('wotp_wor_id');
// if($adm_leave == 1 || $all_work) {
// }else{
// $list_data = $list_data->groupBy('wotp_wor_id');
// }
$list_data = $list_data->paginate($show_count);
//, 'wotp_service_adm_name', 'wotp_grle_name', 'wotp_grpr_name'
$list_items = $list_data->items();
if ($list_items) {
$wor_id = array_column($list_items, 'wor_id'); //工单id
// 获取该工单下的商品信息
$goods_data = DB::table('work_good as wg')
->leftjoin('goods as g', 'g.goo_id', '=', 'wg.wogo_goo_id')
->whereIn('wogo_wor_id', $wor_id)
->select('wogo_id', 'wogo_wor_id', 'wogo_goo_id', 'wogo_goo_name', 'wogo_goo_goods_encode', 'wogo_goo_amount', 'wogo_goo_guarantee', 'wogo_goo_type', 'wogo_state', 'wogo_goo_unit', 'wogo_goo_unta_id', 'goo_unit_conversion')
->get()->toArray();
$wor_create_id = array_unique(array_column($list_items, 'wor_create_id')); //录单人id
$wor_service_adm_id = array_filter(array_unique(array_column($list_items, 'wor_service_adm_id'))); //技师id-负责人
$adm_id_merge = array_unique(array_merge($wor_create_id, $wor_service_adm_id));
// 查询录单人信息
$find_adm = DB::table('admin')
->whereIn('adm_id', $adm_id_merge)
->pluck('adm_name', 'adm_id')->toArray();
$find_dis = DB::table('dispatch_bill')
->where('dego_shop_id', $user_info->adm_shop_id)
->whereIn('dego_wor_id', $wor_id)
->where('dego_order_type', 2)
->pluck('dego_type', 'dego_wor_id')->toArray();
$find_dis_pic = DB::table('dispatch_bill')
->where('dego_shop_id', $user_info->adm_shop_id)
->whereIn('dego_wor_id', $wor_id)
->where('dego_order_type', 2)
->pluck('dego_pic', 'dego_wor_id')->toArray();
foreach ($list_items as $key => $value) {
$list_items[$key]->select = false;
$order_client = DB::table('order_client')
->where('orcl_ord_id', $value->ord_id)
->select('orcl_business_name', 'orcl_buac_name', 'orcl_buac_phone', 'orcl_4sname', 'orcl_name', 'orcl_phone')
->first();
if ($order_client) {
$order_client->orcl_business_name = $order_client->orcl_business_name??'--';
$order_client->orcl_buac_name = $order_client->orcl_buac_name??'--';
$order_client->orcl_buac_phone = $order_client->orcl_buac_phone??'--';
$order_client->orcl_4sname = $order_client->orcl_4sname??'--';
$order_client->orcl_name = $order_client->orcl_name??'--';
$order_client->orcl_phone = $order_client->orcl_phone??'--';
}
$list_items[$key]->order_client = $order_client;
$list_items[$key]->ord_new_type_name = DB::table('order_type')
->where('orty_id', $value->ord_new_type)
->value('orty_name');
// 录单人名称
if ($value->wor_create_id && isset($find_adm[$value->wor_create_id])) {
$list_items[$key]->wor_create_name = $find_adm[$value->wor_create_id];
} else {
$list_items[$key]->wor_create_name = '';
}
// 发货状态
if (isset($find_dis[$value->wor_id])) {
$list_items[$key]->dego_type = $find_dis[$value->wor_id];
} else {
$list_items[$key]->dego_type = 0;
}
// 发货图片
if (isset($find_dis_pic[$value->wor_id])) {
$list_items[$key]->dego_pic = $find_dis_pic[$value->wor_id];
} else {
$list_items[$key]->dego_pic = '';
}
//工单的质检状态
$find_all_wotp = DB::table('wash_work_technician_part')
->where('wotp_wor_id', $value->wor_id)
->select('wotp_submit_state', 'wotp_service_adm_name', 'wotp_service_adm_id', 'wotp_service_data')
->get()->toArray();
foreach ($find_all_wotp as $key1 => $value1) {
if ($value1->wotp_submit_state != 2) {
$list_items[$key]->wor_check_res = $value1->wotp_submit_state;
break;
} else {
$list_items[$key]->wor_check_res = 2;
}
}
foreach ($find_all_wotp as $key1 => $value1) {
if ($value1->wotp_submit_state == 0) {
$list_items[$key]->wor_all_submit = 2;
break;
} else {
$list_items[$key]->wor_all_submit = 1;
}
}
$wor_service_adm_id = DB::table('work_order')
->where('wor_id', $value->wor_id)
->value('wor_service_adm_id');
$num = 0;
foreach ($find_all_wotp as $key2 => $value2) {
if ($value2->wotp_service_adm_name && !empty($list_items[$key]->service_adm_names)) {
if ($wor_service_adm_id == $value2->wotp_service_adm_id) {
$list_items[$key]->service_adm_names = $value2->wotp_service_adm_name.'(组长)' .'、'. $list_items[$key]->service_adm_names;
} else {
$list_items[$key]->service_adm_names = $list_items[$key]->service_adm_names.'、'.$value2->wotp_service_adm_name;
}
} else {
if ($wor_service_adm_id == $value2->wotp_service_adm_id) {
$list_items[$key]->service_adm_names = $value2->wotp_service_adm_name.'(组长)';
} else {
$list_items[$key]->service_adm_names = $value2->wotp_service_adm_name;
}
}
$num++;
}
$list_items[$key]->service_adm_num = $num;
unset($num);
unset($find_all_wotp);
// 质检状态
$find_woch = DB::table('wash_work_check_history')
->where('woch_wor_id', $value->wor_id)
->where('woch_adm_id', $user_info->adm_id)
->select('woch_check_res', 'woch_check')
->orderBy('woch_create_time', 'desc')
->first();
if ($find_woch) {
$list_items[$key]->woch_check_res = $find_woch->woch_check_res;
$list_items[$key]->woch_check_data = $find_woch->woch_check;
} else {
$list_items[$key]->woch_check_res = 0;
$list_items[$key]->woch_check_data = '';
}
if ($value->wor_appoint_time == '0000-00-00 00:00:00') {
$list_items[$key]->wor_appoint_time = '--';
}
// 施工地址
if ($value->wor_address_type == 1) {//门店
$find_address = DB::table('shop')
->where('shop_id', $value->wor_address_id)
->select('shop_id', 'shop_store_name', 'shop_province', 'shop_city', 'shop_address', 'shop_county')
->first();
if ($find_address) {
$list_items[$key]->shop_store_name = $find_address->shop_store_name;
$list_items[$key]->wor_address = $find_address->shop_province.$find_address->shop_city.$find_address->shop_county.$find_address->shop_address;
} else {
$list_items[$key]->shop_store_name = '';
$list_items[$key]->wor_address = '';
}
} elseif ($value->wor_address_type == 2) {
$find_address = DB::table('business_client')
->where('bucl_id', $value->wor_address_id)
->select('bucl_id', 'bucl_name', 'bucl_province', 'bucl_city', 'bucl_address', 'bucl_county')
->first();
if ($find_address) {
$list_items[$key]->shop_store_name = $find_address->bucl_name;
$list_items[$key]->wor_address = $find_address->bucl_province.$find_address->bucl_city.$find_address->bucl_county.$find_address->bucl_address;
} else {
$list_items[$key]->shop_store_name = '';
$list_items[$key]->wor_address = '';
}
} else {
$find_address = DB::table('shop')
->where('shop_id', $value->wor_shop_id)
->select('shop_id', 'shop_store_name', 'shop_province', 'shop_city', 'shop_address', 'shop_county')
->first();
if ($find_address) {
$list_items[$key]->shop_store_name = $find_address->shop_store_name;
$list_items[$key]->wor_address = $find_address->shop_province.$find_address->shop_city.$find_address->shop_county.$find_address->shop_address;
} else {
$list_items[$key]->shop_store_name = '';
$list_items[$key]->wor_address = '';
}
}
$find_wogo_data = DB::table('work_good as wogo')
->leftJoin('service_project as sp', 'sp.sepr_id', '=', 'wogo.wogo_goo_id')
->where('wogo_wor_id', $value->wor_id)
->where('wogo_goo_type', 2)
->select('wogo_goo_id', 'sepr_name', 'sepr_check_car', 'sepr_id', 'wogo_goo_type')
->get()->toArray();
if ($find_wogo_data) {
$sepr_check_car = 2;
foreach ($find_wogo_data as $key1 => $value1) {
if ($value1->sepr_check_car == 1) {
$list_items[$key]->sepr_check_car = 1;
break;
}
}
$service_project = '';
foreach ($find_wogo_data as $key_g => $value_g) {
if (empty($service_project)) {
$service_project = $value_g->sepr_name;
} else {
$service_project = $service_project . '、' . $value_g->sepr_name;
}
}
$list_items[$key]->wor_service_project = $service_project;
} else {
$list_items[$key]->wor_service_project = '';
}
}
foreach ($goods_data as $key => $value) {
// 商品信息
if (empty($value->wogo_goo_id)) {
$goods_data[$key]->wogo_goo_name = '';
$goods_data[$key]->wogo_goo_amount = '';
}
}
} else {
$goods_data = [];
}
$data['current_page'] = $list_data->currentPage(); //当前页面页码
$data['last_page'] = $list_data->lastPage(); //表示最后一页的页码
$data['total'] = $list_data->total(); //总数据个数
$data['current_number'] = $show_count; //一页显示多少个
$data['data'] = $list_items; //返回数据
$data['goods_data'] = $goods_data;
$data['now_time'] = date('Y-m-d H:i:s'); //当前时间
return $data;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论