data_unique_code('分包结算'), 'project_id' => $params['project_id'], 'contract_id' => $params['contract_id'], 'settlement_amount' => $params['settlement_amount'], 'settlement_amount_uppercase' => $params['settlement_amount_uppercase'], 'remaining_amount' => $params['remaining_amount'], 'settlement_date' => strtotime($params['settlement_date']), 'remark' => $params['remark'], 'annex' => !empty($params['annex']) ? $params['annex'] : null, 'add_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 2023/12/29 13:59 */ public static function edit(array $params): bool { Db::startTrans(); try { ProjectSubcontractSettlement::where('id', $params['id'])->update([ 'project_id' => $params['project_id'], 'contract_id' => $params['contract_id'], 'settlement_amount' => $params['settlement_amount'], 'settlement_amount_uppercase' => $params['settlement_amount_uppercase'], 'remaining_amount' => $params['remaining_amount'], 'settlement_date' => strtotime($params['settlement_date']), 'remark' => $params['remark'], 'annex' => !empty($params['annex']) ? $params['annex'] : null, 'add_user' => $params['add_user'], '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 2023/12/29 13:59 */ public static function delete(array $params): bool { return ProjectSubcontractSettlement::destroy($params['id']); } /** * @notes 获取分包结算详情 * @param $params * @return array * @author likeadmin * @date 2023/12/29 13:59 */ public static function detail($params): array { $data = ProjectSubcontractSettlement::field('id,settlement_code,project_id,contract_id,settlement_amount,settlement_amount_uppercase,remaining_amount,settlement_date,remark,annex')->findOrEmpty($params['id'])->toArray(); $project = Project::field('name,project_code')->where('id',$data['project_id'])->findOrEmpty(); $contract = ProcurementContract::field('supplier_id,amount,amount_daxie,contract_no,contract_name')->where('id',$data['contract_id'])->findOrEmpty(); $supplier = Supplier::field('supplier_code,supplier_name')->where('id',$contract['supplier_id'])->findOrEmpty(); $data['project_name'] = $project['name']; $data['project_code'] = $project['project_code']; $data['contract_name'] = $contract['contract_name']; $data['contract_code'] = $contract['contract_no']; $data['supplier_name'] = $supplier['supplier_name']; $data['supplier_code'] = $supplier['supplier_code']; $data['contract_amount'] = $contract['amount']; $data['contract_amount_uppercase'] = $contract['amount_daxie']; return $data; } }