generate_sn(DataReception::class, 'dataid'), 'num' => generate_sn(DataReception::class, 'num'), 'project_id' => $params['project_id'], 'apptime' => $params['apptime'], 'person' => $params['person'], 'number' => $params['number'], 'position' => $params['position'], 'tips' => $params['tips'], 'bidding_file' => $params['bidding_file'] ? json_encode($params['bidding_file']) : null, 'zbkzj_file' => $params['zbkzj_file'] ? json_encode($params['zbkzj_file']) : null, 'gczjht_file' => $params['gczjht_file'] ? json_encode($params['gczjht_file']) : null, 'xmbgqzzl_file' => $params['xmbgqzzl_file'] ? json_encode($params['xmbgqzzl_file']) : null, 'ssgsysjs_file' => $params['ssgsysjs_file'] ? json_encode($params['ssgsysjs_file']) : null, 'wlhj_file' => $params['wlhj_file'] ? json_encode($params['wlhj_file']) : null, 'other_file' => $params['other_file'] ? json_encode($params['other_file']) : null, ]); 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/23 09:21 */ public static function edit(array $params): bool { Db::startTrans(); try { DataReception::where('id', $params['id'])->update([ 'project_id' => $params['project_id'], 'apptime' => $params['apptime'], 'person' => $params['person'], 'number' => $params['number'], 'position' => $params['position'], 'tips' => $params['tips'], 'bidding_file' => $params['bidding_file'] ? json_encode($params['bidding_file']) : null, 'zbkzj_file' => $params['zbkzj_file'] ? json_encode($params['zbkzj_file']) : null, 'gczjht_file' => $params['gczjht_file'] ? json_encode($params['gczjht_file']) : null, 'xmbgqzzl_file' => $params['xmbgqzzl_file'] ? json_encode($params['xmbgqzzl_file']) : null, 'ssgsysjs_file' => $params['ssgsysjs_file'] ? json_encode($params['ssgsysjs_file']) : null, 'wlhj_file' => $params['wlhj_file'] ? json_encode($params['wlhj_file']) : null, 'other_file' => $params['other_file'] ? json_encode($params['other_file']) : null, ]); 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/23 09:21 */ public static function delete(array $params): bool { return DataReception::destroy($params['id']); } /** * @notes 获取详情 * @param $params * @return array * @author likeadmin * @date 2024/02/23 09:21 */ public static function detail($params): array { $data = DataReception::with(['projectInfo'])->findOrEmpty($params['id'])->toArray(); $data['bidding_file'] = !empty($data['bidding_file']) ? json_decode($data['bidding_file'], true) : ''; $data['zbkzj_file'] = !empty($data['zbkzj_file']) ? json_decode($data['zbkzj_file'], true) : ''; $data['gczjht_file'] = !empty($data['gczjht_file']) ? json_decode($data['gczjht_file'], true) : ''; $data['xmbgqzzl_file'] = !empty($data['xmbgqzzl_file']) ? json_decode($data['xmbgqzzl_file'], true) : ''; $data['ssgsysjs_file'] = !empty($data['ssgsysjs_file']) ? json_decode($data['ssgsysjs_file'], true) : ''; $data['wlhj_file'] = !empty($data['wlhj_file']) ? json_decode($data['wlhj_file'], true) : ''; $data['other_file'] = !empty($data['other_file']) ? json_decode($data['other_file'], true) : ''; $head = Admin::field('name')->where('id', $data['person'])->findOrEmpty(); $data['person_name'] = $head?->name; return $data; } }