$params['witness_sampling_id'], 'material_entry_detail_id' => $params['material_entry_detail_id'], 'num' => $params['num'], ]); Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } /** * @notes 编辑工程监理--见证取样明细 * @param array $params * @return bool * @author likeadmin * @date 2024/02/29 09:22 */ public static function edit(array $params): bool { Db::startTrans(); try { SupervisionWitnessSamplingDetail::where('id', $params['id'])->update([ 'witness_sampling_id' => $params['witness_sampling_id'], 'material_entry_detail_id' => $params['material_entry_detail_id'], 'num' => $params['num'], 'update_time' => time() ]); Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } /** * @notes 检验工程监理--见证取样明细 * @param array $params * @return bool * @author likeadmin * @date 2024/02/29 09:22 */ public static function check(array $params,$admin_id): bool { Db::startTrans(); try { SupervisionWitnessSamplingDetail::where('id', $params['id'])->update([ 'check_code' => $params['check_code'], 'check_result' => $params['check_result'], 'check_time' => !empty($params['check_time']) ? strtotime($params['check_time']) : 0, 'check_user' => $params['check_user'], 'check_remark' => $params['check_remark'], 'check_annex' => $params['check_annex'] ? json_encode($params['check_annex']) : null, ]); if(!empty($params['check_problem'])){ foreach($params['check_problem'] as $v){ SupervisionProblem::create([ 'data_id' => $params['id'], 'data_type' => 5, 'problem_cate' => $v['problem_cate'], 'problem_description' => $v['problem_description'], 'problem_name' => $v['problem_name'], 'create_user' => $admin_id, ]); } } Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } /** * @notes 删除工程监理--见证取样明细 * @param array $params * @return bool * @author likeadmin * @date 2024/02/29 09:22 */ public static function delete(array $params): bool { $check_problem = SupervisionProblem::where('data_id',$params['id'])->where('data_type',5)->findOrEmpty(); if(!$check_problem->isEmpty()){ self::setError('该内容下存在验收问题数据,请先删除验收问题数据'); return false; } return SupervisionWitnessSamplingDetail::destroy($params['id']); } /** * @notes 获取工程监理--见证取样明细详情 * @param $params * @return array * @author likeadmin * @date 2024/02/29 09:22 */ public static function detail($params): array { $data = SupervisionWitnessSamplingDetail::withoutField('create_time,update_time,delete_time')->findOrEmpty($params['id']); $material_entry_detail = SupervisionMaterialEntryDetail::field('name,brand,model,contract_brand,entry_number')->where('id',$data['material_entry_detail_id'])->findOrEmpty(); $data['name'] = $material_entry_detail['name']; $data['brand'] = $material_entry_detail['brand']; $data['model'] = $material_entry_detail['model']; $data['contract_brand'] = $material_entry_detail->contract_brand_text; $data['entry_number'] = $material_entry_detail['entry_number']; return $data->toArray(); } }